简体   繁体   中英

Oracle: Regular expression for dot

For example, I have a table "example" which has a column "col1" with string like below

some example text here x2.0.3-a abc
some other example text 1.5 abc
another example text 0.1.4 mnp
some other example text  abc
another example text mnp

I want to select those rows that matches a regular expression. I want the regular expression something like this

any string.any string.any string space abc/mnp or any string.any string space abc/mnp that is the regular expression should match two or three dots, before and after of each dot there should be at least one string(char/number/special chars) and then a single space and then at the end either abc/mnp . What will be the regular expression and sql query for this?

Check on the next regex ^[^.]+?(\\.[^.]+?){1,2} (abc|mnp)$ .

To try the regular expression online, click here .

To get an explanation go to here .

I am not sure if i got your question right , but in case if you are looking to select columns which has any.any or any.any.any in your column then the below regex can help

^.*?(\S+\.\S+).*[ ](?:abc|mnp)$

Demo here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM