Reputation: 1503
I have some text like below:
From these text I need to extract only
I am not comfortable working with regex
. I tried following patterns and I am kind of lost
[A-Z] [0-9A-Z]{4}
Can anybody please help me on this.
Upvotes: 1
Views: 38
Reputation: 626806
You may use
\b[0-9A-Z]{4}\s+(.+)
See the regex demo. Capturing group 1 will hold the value you need.
Details
\b
- a word boundary[0-9A-Z]{4}
- four chars that are either uppercase letters or digits\s+
- 1+ whitespaces(.+)
- Group 1: any one or more chars, other than line break chars, as many as possible.As an answer to the comment, you may consider
^(?:\S+\s+){4}(.+)
See another regex demo. It matches
^
- start of string(?:\S+\s+){4}
- four occurrences of 1+ non-whitespace chars followed with 1+ whitespace chars(.+)
- Group 1: any one or more chars, other than line break chars, as many as possible.Upvotes: 2