Regex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2024 04:26 AM
Hi All,
I am using regex to get a alphanumeric value from a string . The regex i used is [A-Za-z0-9] . Please help me on this .
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2024 12:41 AM
Hi
try this
var reg = /[a-zA-Z]*\d+[a-zA-Z]*/g; //Checks for both text and digits in the beginning
var subject ="This is a sample case for wefWF123AZBzxc";
var text = subject.match(reg);
gs.info(text[0]);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2024 12:43 AM
Hi @Simon Christens ,
var subject = "This is a sample case for A1BCDD2F(2000-07-03)";
the regex should return only A1BCDD2F . Please suggest a different regex and thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2024 03:41 AM - edited 07-03-2024 03:46 AM
Hi again kali
Try this regex instead then
var reg = /[a-zA-Z0-9]*\d+[a-zA-Z]/g;
So
var reg = /[a-zA-Z0-9]*\d+[a-zA-Z]/g; //Checks for both text and digits in the beginning
var subject ="This is a sample case for A1BCDD2F(2000-07-03)";
var text = subject.match(reg);
gs.info(text[0]);
This returns
03/07/2024 12:39:55 (147) A1BCDD2F
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2024 01:26 AM
Hi @Simon Christens,
Thnaks for your response , sorry i could not reply back the regex should find alphabumeric value from the string and get digits value from the string.
var subject = "This is a sample case for A1BCDD2F(2000-07-03)";
var subject = "This is a sample case for 89076523";
The regex should get value from both A1BCDD2F and 89076523; Kindly help me on this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2024 03:33 AM
Hi again,
Well then i dont know which scenarios you are looking for really but you can try this:
var reg = /[a-zA-Z0-9]*\d+[a-zA-Z]|\d+$/g; //Checks for both text and digits in the beginning
This also checks and gets x digits at the end of the
var reg = /[a-zA-Z0-9]*\d+[a-zA-Z]|\d+$/g; //Checks for both text and digits in the beginning
var subject ="This is a sample case for 89076523";
var text = subject.match(reg);
gs.info(text[0]);
08/08/2024 12:31:47 (771) 89076523