- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2017 04:35 PM
Hi,
I need to extract the sys_id from a string:
bla bla bla name="sys_id" value="SYSID"
Example: parameter name="sys_id" value="bd3192d73739b200166ed2e843990e40"
So I have this:
var regexp = /name="sys_id" value="([^{32,}$])/;
var out = (current.u_text.match(regexp))[1];
gs.addInfoMessage('out is ' + out);
The infoMessage shows: out is b
The sys_id is bd3192d73739b200166ed2e843990e40, so I get the first character.
Also tried: var regexp = /name="sys_id" value="([^\w{32,}$])/; and all kind of combinations with [a-z0-9].
Your thoughts are welcome.
Harel
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2017 04:44 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2017 04:44 PM
Have you tried the simple approach?
var regexp = /[0-9a-f]{32}/;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2017 12:01 AM
Hi Chuck,
Thanks for the reply.
I tried that as well. Same output: out is b .
When I test in a regular expression tester, both your string and mine \w{32} work.
I'm baffled.
Also adding bernyalvarado who helped me a long time ago with the same subject.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2017 12:26 AM
Hi Chuck,
So in the end, your suggestion did the trick. I ignored the string that comes before the sys_id.
var regexp = /[0-9a-f]{32}/;
var out = (current.u_text.match(regexp));
Out of curiosity (and for future needs), what should I use if I want to extract a string (like a sys_id) from another string (like a whole sentence)?
harel

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2017 06:10 AM
If you are looking for a solution to get a sys_id from a whole sentence, it is highly unlikely that the sentence will randomly have 32 hexadecimal characters in it - that's what makes the sys_id so easy to identify. That same pattern will work. It just says look for 32 consecutive characters as long as they are 0 through 9 or a-f. If it doesn't match that, I don't care.