Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Skip the first 3 leading characters using RegEX

Tags:

regex

I am looking for a RegEX that would match/select all but the first 3 characters of a string (including whitespace). That is, select from the 4th character onwards, and if there is no 4th (or 3rd, or 2nd) character, there will be no match.

EX1. Given String: "ABC COMPANY"

RegEX should match " Company"

EX2. Given String: "JASON'S PAINTING"

RegEX should match "ON'S PAINTING"

EX3. Given String "AB"

RegEX should not match anything.

I have been able to come up with an expression that would match only the first the characters ^.{3}\s*, but this is the invert of what I would need.

This is not being used in any programming language so I cannot use string manipulation. For context, this is using Oracle's Enterprise Data Quality RegEX Replace processor.

Thanks in advance.

like image 589
lewpie Avatar asked Dec 15 '22 00:12

lewpie


2 Answers

I don't know whether the Oracle's Enterprise Data Quality RegEX Replace processor supports the Lookaround or not. But Here is the usual regex if it supports:

(?<=^...)(.*)

Here using positive lookbehind (?<=^...) it is checking that the match is after the three characters from the begin.

Online Demo

like image 172
Sabuj Hassan Avatar answered Dec 28 '22 15:12

Sabuj Hassan


I'm a rookie with regex, but try: (?<=.{3}).+

The part within the parentheses is a positive lookbehind - it gives up the match and only return whether a match afterwords is possible or not. The .+ token means there have to be at least one character. If you know all the characters will be word characters (0-9 a-z A-Z and underscore) or a whitespace, I recommend replacing the later dot with [\w\s].

like image 34
Maayan Avatar answered Dec 28 '22 15:12

Maayan