Can I use regular expression in url?

  • Questions
  • Can I use regular expression in url?
Question ID: 105381

Browser("CreationTime:= 0").Page("url:=" &".*" & pageURL&".*")

Can I replace this code with the following ?

Browser("CreationTime:= 0").Page("url:=.*" & pageURL&".*")

Marked as spam
Posted by (Questions: 188, Answers: 22)
Asked on April 29, 2014 4:35 pm
Answers (1)
Private answer

Technically, following the rules of regular expressions, you should be able to use them in the code you listed. By using the .*, this implies that the preceding value can be empty of any combination of characters leading up to the pageURL variable value, followed by the same regular expression on the trailing end, which can also be empty if it is not needed.

Browser(''CreationTime:= 0'').Page(''url:=.*'' & pageURL & ''.*'')

If for some reason it doesn't work, you can also try the alternative way of using a variable with the programmatic description including regular expressions, such as:

var_URL=''.*'' & pageURL & ''.*''
Browser(''CreationTime:= 0'').Page(''url:=''&var_URL)

** Don't forget that if you have an object you want to work with that is a child of the Page object, you will need to continue the programmatic description for the whole object hierarchy. If you have web button to click on the Page, you will need to continue using the pattern, such as:

Browser(''CreationTime:= 0'').Page(''url:=.*'' & pageURL&''.*'').WebButton(''value:=OK'').Click

Marked as spam
Posted by (Questions: 2, Answers: 438)
Answered on April 29, 2014 4:36 pm