Hi I am new to the regex I am trying to match the pattern for bellow line
T071108452T 42D896D5O 3587
I want to match the pattern till T071108452T 42D896D5 and after this i want the Character "O" to match i tried something like this
(T)(\d{9})(T)(\d{0,19}\s{0,19}\w{0,19})O
but it contains the "O" already with the \w{0,19} and i want to match "O" as specific character any help will be great thanks .
As for the more values are
T065000090T203 93 5797 9O 4037
T325170628T0108626004D18O01054
T071108452T 42D896D5O 3587
So i want to match "T"-- then 9 digits then -- "T" and then any combination that is alphanumeric till --"O"
Say you have the following string:
If you want to match until the last
O, you may use the following pattern:[\w\s]+(?=O)This means:
[\w\s]+match words and whitespaces one or more times, greedy.(?=O)Zerowidth lookahead assertion to match untilOfoundNow if you want to match until the first occurence of
Othen you may use the following pattern:[\w\s]+?(?=O). Note the added question mark, it's to match ungreedy.Note:
\wwill also match an underscore, you may replace[\w\s]by[^\W\S_]to prevent that. Note the negation and the uppercased letters.