TechNow Ep 31 | Regular Expressions Part 1 of 2

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2016 01:32 PM
Chuck, Dave, and Kreg are back to help you understand the world of regular expressions. These powerful patterns can be extremely useful in scripting, Edge Encryption, and more. The team starts out with very simple examples and constructs. Find out how to understand, build, and maintain your regular expressions to take advantage of some very powerful features.
Originally aired Thursday October 13, 12:00PM PDT
(Be sure to change your YouTube Setting to 720HD)
Ask your questions below on this discussion page.
And Please Let our Expert Know how they've helped! Comment Below!
Like, Share, Mark Helpful.
Featured Experts
Chuck Tomasi is a Platform Architect for ServiceNow. He is a computer science major with over 30 years of IT experience. As a former ServiceNow customer, Chuck won the first Innovation of the Year Award at Knowledge 10. Since joining ServiceNow in 2010 as a Technical Consultant, he has done many large scale ITSM implementations and custom applications, acted as an adjunct instructor for Education Services, created and lead the Technical Best Practices program, and co-hosts the ServiceNow series "TechNow".
Dave Slusher has been developing software for 20 years for companies such as Intel, Orbitz, Dell Secureworks and many startups lost to history. He has been with ServiceNow for two years, first in Expert Services and now as the Developer Evangelist for the developer community and portal. He earned his BS from Georgia Tech and his MS in Computer Science from the University of Louisiana - Lafayette.
Kreg Steppe is a Senior Curriculum Developer within ServiceNow developing and supporting cloud training infrastructure. He specializes in developing integration solutions, automating repeatable processes and Cloud Management in ITOM. Kreg's prior experience includes operating his own ISP, developing web applications in PHP, network integration, managing network support, Application Development on cloud based networks, DNS and email server maintenance. He is a Linux enthusiast and enjoys Photography.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2016 05:58 AM
Thanks for the great video! I had to watch it to find out what StringRuler() was.
If any of you would like to know what the below regex does and how it works, please see my blog GQL (Glide Query Language) Part 3: The Parser
var regex = /SELECT\s*([^]+?)\s*FROM\s*(.+?)\s*(?:WHERE\s*([^]+?(?=\s*LIMIT)|[^]+?)\s*)?(?:LIMIT\s*([,\d\s]+?)\s*)?$/
This uses many topics covered in this video, plus some.
Also, another regex tool I like, which is not mentioned here, is
HiFi Regex Tester - Live JavaScript Regular Expression Tester
It highlights matches in place, which I find useful.
Please feel free to connect, follow, mark helpful / answer, like, endorse.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-10-2016 04:16 PM
Thanks for the video. It is really helpful.
Can I ask you a question about regular expression for condition type field?
I am working on a project, we need to ship data. So I have to write regex as a condition filed in a table instead in Script Include. But I find when we create a pattern string for the condition field in the platform, it will have syntax error.
If I implement it in script include like var pattern = '/[A-Z]/'; It could work well. However we need to remove quotation and slash when we enter regular expression for condition field in platform. And I still can not use falg i such as (?i) or '/[A-Z]/i' to make the match insensitive. Do you meet the same question? And could you give me some suggestion for this implementation? Thank you very much.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-10-2016 05:06 PM
Hi Nicole,
Are you referring to the conditional operator "matches regex" (as seen in some string field conditions)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-10-2016 05:46 PM
Hi Chuck,
Yes, thanks for your reply. I read some blogs and find some useful information. This problem has been solved.
ServiceNow automatically adds a "/^" at the start of the RegEx condition. The content of the field corresponding to the javascript regex as it is within the enclosing forward slash '/'. E.g if we enter "some text" of the condition field, the equivalent javascript regex would be similar to /^some text/. This means that it may not be possible to use the flags that would appear after the trailing slash.
I see a solution someone proposed in another blog. We could instantiate a GlideFilter 'filter' using the MATCH_RGX condition string operator. Then use function filter.setCaseSensitive(false). Finally we could make the RegEx insensitive when we call the match() function.
You could check this blog about RegEx in condition builder. RegEx in condition builder
Thanks,
Nicole

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-10-2016 06:28 PM
Thanks for the info Nicole. I'll test it out and keep it handy.