Can someone help me create a regex or transformation regex to achieve below pattern please. I am new to create this regular expression
when designing a regular expression you need to know two things:
a) What is your input set
b) What is the desired outcome
Your example gives us an idea of what a part of your input set might look like, but we don't know what the pattern is that the other strings in that set follow, or if there is one.
Then, what would you like the regex to do? Find exactly this string? Or find all key/value pairs that start with RTR and extract their value? It would be best if you explained what your aim is in a bit more detail.
I want to find the string above. However this query string will have few dynamic value. Below is the details around it.
A query will have
Starting from here. a query ca have multiple RTRPrompt and RTRRowId. If RTRPrompt are 3 (Ex - RTRPrmopt0/1/2.. then associated RTRRowId will be there (like RTRRowId0/1/2..)
thanks for the details. The first rule of regex, generally, is to not use them unless absolutely necessary, as they can be a bit of a performance issue.
In your case, is there a reason why a "starts with: RTRRtf=GotoView&RTRView=" wouldn't work? I.e., is there a lot of similar queries and you're only interested in a specific subset of them?
Or is this query string a substring of some longer string that you'd like to extract via a transformation regex? Then we'd need to know what the string looks like before and after the part you're interested in. Best regards,
Sorry for delayed response.
Using only RTRRtf=GotoView&RTRView=" , It would not work as there are dynamic content in the query string.
This is the query string for a specific screen or a page. This string will have common parts for each page. for example - 1, 3 and 5 are always static. 2,4 and 6 are always dynamic because, these are value for 1,3 and 5.
Depending on where user is navigating in a screen, 7 and above would pop up.
ok, but all of them _start_ with the fixed text RTRRtf, right? So instead of making a regex you could simply use a "starts with" criterion, or am I misunderstanding your requirements?
Otherwise, an example regex could look like this:
the first .*? would mask stuff like GotoView (if there could be other strings in that place). The last .* will match the rest of the query.
The dot matches any character, the asterisk repeats the match and the question mark tells it to be non-greedy (i.e. only match till the next part of the regex occurs).
Experiment a bit with this and let us know if you need more details, cheers,