I am writing a Rational Functional Testing (RFT) script using Java language where I am trying to create an object in my object map with a regular expression not to match a certain pattern.
The URL which I want not to match will look something like:
http://AnyHostName/index.jsp?safe=active&q=arab&ie=UTF-8&oe=UTF-8&start=10
http://AnyHostName/index.jsp?safe=active&q=arab&ie=UTF-8&oe=UTF-8&start=40
http://AnyHostName/index.jsp?safe=active&q=arab&ie=UTF-8&oe=UTF-8&start=210
I tried using the below expression but since the end of the URL is also any number of two or more digits the expression failed to fulfill the need:
^.*(?<!\start=10)$ or ^.*(?<!\start=40)$ or ^.*(?<!\start=110)$
If i tried using \d+ to replace the number in the above patterns, the expression stopped working correctly.
Note: It is worth to mention that using any Java code will not be possible since the regular expression will be given to the tool (i.e. RFT) and it will be used internally for matching.
Any help please on this matter?
Use this expression:
^(?:(?!start=\d+).)*$
It has the advantage that it excludes also the cases where start=10
appears in the middle of the URL (i.e. http://AnyHostName/index.jsp?safe=active&q=arab&start=210&ie=UTF-8&oe=UTF-8
).
It can be slow, though, since it's checking the negative look-ahead for every character.