Gaurav07
(Gaurav Bahuguna)
October 31, 2019, 11:46am
1
String can be any one of the two
Intention: Singapore – SRC Refinery , here output should be - Singapore
Intention: Singapore , here output should be - Singapore
Intention: SRC Refinery – Singapore , here output should be - SRC Refinery
No matter what the string is I want output as the first complete name after intention: and before –
Regex.Match(sampleString, “(?<=Intention:)(.+)(?=–)”).Value
2 Likes
monika.c
(Monika Chaudhari)
October 31, 2019, 11:52am
3
System.Text.RegularExpressions.Regex.Match(Str, “(?<=Intention:).*”).value
Gaurav07
(Gaurav Bahuguna)
October 31, 2019, 1:57pm
4
Can you explain the syntax like whats the role of ?<= and other symbols
kadiravan_kalidoss:
?<=
?<= —> Startswith String regex pattern
?= —> endswith String regex pattern
Gaurav07
(Gaurav Bahuguna)
November 1, 2019, 3:49am
6
what is the role of .+ after Intention:)(
monika.c
(Monika Chaudhari)
November 1, 2019, 4:53am
7
@Gaurav07
. Matches any character other than newline (or including newline with the /s flag)
+ Matches one or more
Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET.
abhay
(Abhay)
November 1, 2019, 5:18am
8
(?<=Intention:)\s*\w*\s*(\s|\w*)
abhay
(Abhay)
November 1, 2019, 5:20am
9
" . " Matches any character other than newline
" + " Matches one or more
Gaurav07
(Gaurav Bahuguna)
November 1, 2019, 5:28am
10
tx… so this picks up the value between intention: and -
Now if I want to pick value between intention :(in the beginning) and in the end there can be – or- or /
Here I know the string will start with intention : but it can end with either - or / or –
Please provide code for such cases
amaresan
(Amaran)
November 1, 2019, 6:41am
11
@Gaurav07
(?<=Intention:).*?(?=–|-|_)
Gaurav07
(Gaurav Bahuguna)
November 1, 2019, 7:20am
12
tx…
Now I have a string
WS 50.81 - Overage 50%
from this I need to take a value present after WS(50.81) and its not fixed that there is a - after it, there can be anything else, so basically I need the decimal number present after WS.
Similarly I want the no 50 present after Overage…
1 Like
Gaurav07
(Gaurav Bahuguna)
November 1, 2019, 7:33am
14
tx and this one also
$35,000 – per day/pro rata - 120 hours
I need just 35000 from this string
Gaurav07
(Gaurav Bahuguna)
November 2, 2019, 4:05am
17
its not necessary that there will be a - after 35000, only thing fixed is the $ sign, it can be like this
$35000 – per day/pro rata - 120 hours ( space between and 35000)
$35000 – per day/pro rata - 120 hours ( no space)
Hi @Gaurav07 ,
You can use this pattern to match the first complete name after intention:
Pattern = “(?<=Intention: )[A-Za-z ]+”
Gaurav07
(Gaurav Bahuguna)
November 4, 2019, 7:15am
19
its not necessary that there will be a - after 35000, only thing fixed is the $ sign, it can be like this
$35000 – per day/pro rata - 120 hours ( space between and 35000)
$35000 – per day/pro rata - 120 hours ( no space)