RegEx in condition builder
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2012 02:16 AM
Hello,
In the condition builder we now have the 'matches regex' operator. ...But what are all the regex we CAN use in it?
For example: beginning of line operator '^' does not play nicely with the condition builder in this case as it is assumed it means AND and will add a second condition when saving.
Is there some other character denoting beginning of line for the condition builder? What other exeptions might there be and do they have workarounds?
thanks in advance,
Jaakko Jalo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2016 11:46 PM
Hi Johnny - Update:
I tried many different things to get a report source working using "matches regex" - impossible.
There is still a problem ticket open with ServiceNow.
I checked it in Helsinki as well and there also appears this error: "Syntax Error or Access Rule Violation detected by database (You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MATCH_RGX 'INC[0-9]{7}' GROUP BY timeref ORDER BY timeref' at line 1 Query is:..."
So unfortunately Development hasn't fixed this one yet.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2016 07:12 AM
Yes, the MATCH_RGX needs to be replaced in several places with REGEXP, from what I understand.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2016 09:04 AM
Hi Johnny, this error is annoying.
I created a workaround. If you want to have a look: Re: Matches Regex in Condition Builder
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2016 05:57 AM
hi Johnny,
I have a similar requirement like this.
I have a string like Building\Floor\Space\
My requirement - I want to replace all '\' with ',' and then split the result like:
Building
Floor
Space
How this can be achieved?? Looks like ServiceNow does not recognize '\' as a regex.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2016 11:24 PM
Hi Kunal,
here is a solution for your problem. It is all about escaping the backslashes.
Just try it in the browser console:
var t = "Building\\Floor\\Room"
var rex = new RegExp('\\\\','g');
var z = t.replace(rex,',\n');
Results in:
"Building,
Floor,
Room"
Hope it helps.
