This question already has answers here:
How can I match "anything up until this sequence of characters" in a regular expression?
(15 answers)
Closed 3 years ago.
I have strings that are concatenations of airline codes/flightnumbers, separated with ;. The airline code and flight number are either separated by a space or -. So some examples are:
AA-1234;UA 243;EK 23;
9W 23;B6-134
Now I want to grab the airline codes from this.
I came up with the following regex: [a-zA-Z0-9]{2}[ -]. This works to grab the airline codes but also includes the airlinecode-flightnumber separator. How would I adjust my regex to not include this?
[a-zA-Z0-9]{2}(?=[ -])
See it in action here
Related
This question already has answers here:
Delete all content but keeping matched
(1 answer)
How do (*SKIP) or (*F) work on regex?
(2 answers)
Closed 5 months ago.
I'm trying to remove all characters except those sandwiched between 2 strings,
my original text:
BlahBlahBlahBlahBlahbeginningMY,IMPORTANT,text,1endblahblahblahblblah
XXXXXXXXXXXXXXXXXXXXbeginningMY,IMPORTANT,text,2endblahb2XXXXXXXXXXXX
YYYYYYYYYYYYYYYYYYYYbeginningMY,IMPORTANT,text,3endYYYYYYYYYYYY
UUUUUUUUUUUUUUUUUUUUbeginningMY,IMPORTANT,text,4endUVUVUVUVUVUVUVUVUV
The desire output:
beginningMY,IMPORTANT,text,1end
beginningMY,IMPORTANT,text,2end
beginningMY,IMPORTANT,text,3end
beginningMY,IMPORTANT,text,4end
I used this
beginning(.*)end
RegEx in regexr.com and got a useful list like this
I'm not allowed to upload my data to any website so how can I do this On Notepad++ ?
This question already has answers here:
Regex for one or more words separated by spaces
(2 answers)
Closed 2 years ago.
Data
"06/12/20 ,NOVUS HOME MORTGAGE
04/22/20 ,CAP ONE NA
04/22/20 ,CAPITAL ONE
04/22/20 ,CAPITALONE
04/16/20 ,CREDCO
04/16/20 ,CREDCO
04/16/20 ,FLAGSTAR BANK OA R"
Regex : "[A-Z\s]+"
The result I wanted is NOVUS HOME MORTGAGE, CAP ONE NA etc all the data . but it includes space , how not to include space ? it did include the space before , I dont wanna include space
The \s will match any white space character. So removing might solve what you are asking for. (I don't fully understand your question and what you want, so just providing a suggestion)
This question already has answers here:
Getting the text that follows after the regex match
(5 answers)
Closed 4 years ago.
I have a line containing
[India,sn_GB] Welcome : { Name:{Customer1},Place:{Mumbai},}
I want to print the entire line after sn_GB] in splunk, which is
Welcome : { Name:{Customer1},Place:{Mumbai},}
I used the below regular expression:
(?<=sn_).*?$
But it prints, along with GB] like GB] Welcome : { Name:{Customer1},Place:{Mumbai},}.
In the word sn_GB, sn_ is constant and the rest two letter will vary, like GB, LB, KB, TB as such.
Please help me in correcting the regular expression.
Thanks
This will give the correct result in case sn_GB is constant.
(?<=sn_GB).*?$
If GB is not constant you can go for:
(?<=sn_...).*?$
I understand your question now.
Country codes are always 2 letters.
i'd use
(?<=sn_..\]\ ).*$
but you could use
(?<=sn_[A-Z]{0,5}\]\ \s*).*?$
(?<=sn_....).*$
is the simplest, as it will just grab 4 characters after, if it's always 2 letters for country code, and then a closing bracket and a space
This question already has answers here:
What do 'lazy' and 'greedy' mean in the context of regular expressions?
(13 answers)
Closed 5 years ago.
I have a piece of text that I need to match anything between <latex and </latex> but not the text and an equivalent quantity of
Which given has the same divisor of <latex>5</latex> and an equivalent quantity of <latex>(5 + 2) \div 5</latex>?
I've tried with the regex \<\;(latex).+(latex)\>\;([^\s]) but it doesn't stop until the last </latex>in the line.
You need to use a non-greedy match
\<\;(latex).+?(latex)\>\;
This question already has answers here:
Regular expression to match a line that doesn't contain a word
(34 answers)
Closed 6 years ago.
I have several lines win one word in each in my Notepad++. How to select all words not not containing Set ant Get phrase.
SetBlaBla1
BlaGetBla2
BlaBla3
Result should be BlaBla3
Try negative look-ahead, something like this:
^((?!Set|Get).)*$