
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2022 01:27 PM
I'm struggeling with some RegEx to filter out values from a text-file. RegEx is used in a custom pattern I've created, but I can't get it to match in the pattern.
I've tried it on RegEx101 but I can't get it to match in the pattern.. Anyone here that can give me some examples of what might work?
The file will have two lines. The first with headers and the second one with data.
I'm looking for matching on the second row only. See screendump of what values I want to catch:
Text in file:
HOST_NAME#DB_NAME#INSTANCE_NAME#DB_STATUS#STANDBY_HOST_NAME#dbversion#db_size_gb#dg_status#is_rac#partition_used
my1#my2#my3#my4#my5#my6#my7#my8#my9#my10
RegEx Used to match:
\n.+?\#.+?\#(.+)?\#.+?\#.+?\#(.+)?\#(.+)?\#(.+)?\#(.+)?\#(.+)?
But using the same RegEx in my Pattern does not work. It's not matching:
But I have this below RegEx and this one works but only on the first row, and that row is only for headers:
.+?\#.+?\#(.+?)\#.+?\#.+?\#(.+?)\#(.+?)\#(.+?)\#(.+?)\#(.+)
I have tried to add "\n" in the start of the RegEx but then it does not work anymore in ServiceNow pattern.
Anyone here who can figure out what I should do to make it work?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2022 03:10 AM
Found a better regex to fit my needs, but I also managed to change the output of the file and not look on the second line anymore. Not the desired fix, but it did the job and therefore I'm closing the post based on this.
RegEx used instead:
.*?\#.*?\#(.*?)\#.*?\#.*?\#(.*?)\#(.*?)\#(.*?)\#(.*?)\#(.*)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2022 03:10 AM
Found a better regex to fit my needs, but I also managed to change the output of the file and not look on the second line anymore. Not the desired fix, but it did the job and therefore I'm closing the post based on this.
RegEx used instead:
.*?\#.*?\#(.*?)\#.*?\#.*?\#(.*?)\#(.*?)\#(.*?)\#(.*?)\#(.*)