How to select a whole word inside Positve Lookbehind scope in Regex
For eg:- (?<=BILL TO SHIP TO INVOICE TOTAL\nNetflix\s)\w+\s\w+
In above Regex expression example, to make it more generic i need to write expression instead of specific word “Netflix”
So how to write it…?
Anil_G
(Anil Gorthi)
2
@Bhavesh_Batra
You can do like this
“(?<=BILL TO SHIP TO INVOICE TOTAL\n” + variableName + “\s)\w+\s\w+”
Hope this helps
Cheers
Sir, my question was instead of “Netlix”, it could be any word so how do i select that word
using a variable won’t help as i don’t have any pre-assigned value.
Anil_G
(Anil Gorthi)
4
@Bhavesh_Batra
Then try this
(?<=BILL TO SHIP TO INVOICE TOTAL\n[A-Za-z]+\s)\w+\s\w+
Cheers
It is showing an error on + quantifier
" + A quantifier inside a lookbehind makes it non-fixed width "
Anil_G
(Anil Gorthi)
6
@Bhavesh_Batra
Where are you using it can you show please
Cheers
I want to Extract Aman Basra from this string, but i want to make generic so that any name would be extracted
Anil_G
(Anil Gorthi)
8
@Bhavesh_Batra
Please select .net flavour then the error would be gone
Cheers
1 Like
ppr
(Peter Preuss)
9
keep in mind windows linebreak \r\n
so we do use defensive \r?\n
for this
1 Like
system
(system)
Closed
11
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.