I am trying to use a regular expression to get everything after the "\" in an account name for the author of an item. Examples of an account name for my site are "i:0#.w|mydomain-corp\doej" for a corporate user and "i:0#.w|mydomain-corp\doej" for an external user. I can successfully do this with several extra actions and the fn-Remove() inline function but since the removed lengths for an internal and an external user are different, I thought regex might be a bit more elegant and not require me to use a Set a condition action. I tried the following pattern but it includes the backslash and I am a noob at regex.
Can anyone correct my pattern?
Thanks and Regards,
Solved! Go to Solution.
Yes, as a matter of fact, I did make that work. I used the following patrtern...
...that I had found in another post. This leaves me with only the userID if I leave the Replacement text input box empty. I have a working solution now but for acedemic's sake, I am wondering what is wrong with my original pattern. Any idea?
Pattern \\(.*) matches a backslash followed by zero to unlimited number of characters. The capturing group () is not necessary, \\.* would do the same here.
Use positive lookbehind (?<=\\) to match only the characters after the backslash by extract function:
Tha worked @mlauer. So the positve lookbehind is always (?<=\\) with positions 5 or in my case 5 and 6 due to the special of reserved character neededing to be escaped, being the character to look behind?
The extract function has the .*$ at the end. The regex site I am looking at reads:
.* matches any character (except for line terminators)...
* Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)...
$ asserts position at the end of a line...
I think I understand the first two (look for ANYthing else... and ...look at all of the rest) but help me understand the $. Why is that needed?
Thanks and Regards,