Srini_M
(Tinku)
September 30, 2021, 7:47am
1
Hi Team,
I need to extract the string using regex
Input string1: S No: 100-18675364
Input String2: S No: 1A2984836583
Regex pattern:(?<=S\s+No:\s*)(\w*\d+\w*|\d+)
using the above regex am able to extract the input string 2 and from input string 1 am getting till 100 , its not picking the after hypen(-). Could some one help me on this.
Yoichi
(Yoichi)
September 30, 2021, 7:51am
2
Hi,
How about the following pattern?
(?<=S\s+No:\s*)[-\w]+
Regards.
dimibot
(Dimitrios)
September 30, 2021, 7:53am
3
You can use this pattern:
(?<=S\s+No:\s*)([A-Z0-9-]+)
Inside [ ] you can specify exactly which characters you need.
if not mistaken \w is equilevant to [a-zA-Z0-9_]
Maybe you don’t want to capture underscore (_)
Srini_M
(Tinku)
September 30, 2021, 9:36am
4
Thankyou, \w working fine.
Also, i have one more text
Date SNO #
09/22/2021 238258-00
How to get the 238258-00 using regex?
Srini_M
(Tinku)
September 30, 2021, 9:38am
5
Thankyou for the quick response. Its working fine
Date SNO #
09/22/2021 238258-00
How to get the 238258-00 using regex?
Charbel1
(Charbel)
September 30, 2021, 12:16pm
6
You can try the following expression:
(?<=\/\d{4}\s)[-\w]+
Srini_M
(Tinku)
September 30, 2021, 2:20pm
7
Hi, wants to take preceding token also to identity that in the text file. How to get along with preceding token.
Srini_M
(Tinku)
September 30, 2021, 2:32pm
8
Charbel1:
(?<=\/\d{4}\s)[-\w]+
thanks for quick help.
String1:
simple text sample sample Group, sssustomer SO # Page #
565 E hjfguy wve 89876757 1 of 1
need to extract 89876757 from below string1:
String2:
S final 5.09
need to get the 5.90
can u also give me any website we can try to create the expression.
Charbel1
(Charbel)
October 1, 2021, 5:07am
10
What do you mean by preceding token?