I am not able to proceed further and spent whole time to do google but didn't find a solution for my below query.
I want an Oracle regular expression that will meet the following requirements:
starts with ABCD followed by variable length alphanumeric with 'N'
present at 3nd or 4rd place from right.
E.g. ABCD201312102751N11 or ABCD201312102751N121.
The regex you can use is:
^ABCD[[:alnum:]]+N[[:digit:]]{2,3}$
EXPLANATION:
^ - Start of string
ABCD - Literal ABCD
[[:alnum:]]+ - Alphanumeric characters, 1 or more occurrences
N - a literal N
[[:digit:]]{2,3} - 2 or 3 digits (no more, no less)
$ - End of string.
See demo
Related
I need to build a regex that have the following:
Rules to be applied:
exactly 14 characters
only letters (latin characters) and numbers
at least 3 letters
Regex still confuses me so I am struggling to get the correct output. I want to use it with swift and swiftui in an app I am making
(?=(.*[a-zA-Z]){3,}([0-9]){0,}){14,14}$
I tried this. But I know it is not the way
I would use a positive lookahead for the length requirement:
^(?=.{14}$)(?:[A-Za-z0-9]*[A-Za-z]){3}[A-Za-z0-9]*$
This pattern says to match:
^ from the start of the input
(?=.{14}$) assert exact length of 14
(?:
[A-Za-z0-9]*[A-Za-z] zero or more alphanumeric followed by one alpha
)
[A-Za-z0-9]* any alphanumeric zero or more times
$ end of the input
You need to use
^(?=(?:[0-9]*[a-zA-Z]){3})[a-zA-Z0-9]{14}$
Details
^ - start of string
(?=(?:[0-9]*[a-zA-Z]){3}) - at least three repeations of a letter after any zero or more digits sequence required
[a-zA-Z0-9]{14} - fourteen letters/digits
$ - end of string.
See the regex demo.
I would like to have an expression to validate the plates of monaco.
They are written as follows:
A123
123A
1234
I started by doing:
^[a-zA-Z0-9]{1}?[0-9]{2}?[a-zA-Z0-9]{1}$
But the case A12A which is false is possible with that.
You can use
^(?!(?:\d*[a-zA-Z]){2})[a-zA-Z\d]{4}$
See the regex demo. Details:
^ - start of string
(?!(?:\d*[a-zA-Z]){2}) - a negative lookahead that fails the match if there are two occurrences of any zero or more digits followed with two ASCII letters immediately to the right of the current location
[a-zA-Z\d]{4} - four alphanumeric chars
$ - end of string.
You can write the pattern using 3 alternatives specifying all the allowed variations for the example data:
^(?:[a-zA-Z][0-9]{3}|[0-9]{3}[a-zA-Z]|[0-9]{4})$
See a regex demo.
Note that you can omit {1} and
To not match 2 chars A-Z you can write the alternation as:
^(?:[a-zA-Z]\d{3}|\d{3}[a-zA-Z\d]|\d[a-zA-Z\d][a-zA-Z\d]\d)$
See another regex demo.
So it needs 3 connected digits and 1 letter or digit.
Then you can use this pattern :
^(?=.?[0-9]{3})[A-Za-z0-9]{4}$
The lookahead (?=.?[0-9]{3}) asserts the 3 connected digits.
Test on Regex101 here
I would like to build up a regex expression that checks in the text if the string contains a single dot between numbers and that there are more then one number.
My text example would be:
11.00 11.000 1.0 1 1 2.
I would like to check that text contains only single dot and I would to check text contains more then one number either 1 or like this 111.00. How can I do this.
My current expression checks for more then one dot and it not checking if the text contains more then one value of the correct format 1.1 or 1. Also I am checking for new lines and any number of spaces as follows:
/^[0-9 .\n\t]*$/
You can use
^\d+(?:\.\d+)?(?:\s+\d+(?:\.\d+)?)+$
See the regex demo.
Details
^ - start of string
\d+(?:\.\d+)? - one or more digits and then an optional occurrence of . and one or more digits
(?:\s+\d+(?:\.\d+)?)+ - one or more occurrences of
\s+ - one or more whitespaces
\d+(?:\.\d+)? - one or more digits and then an optional occurrence of
$ - end of string
I'm having issues with the validation of the chilean RUT/RUN with a regex expression in PCRE. I have the next regular expression but sadly can't make it work:
\b[0-9|.]{1,10}\-[K|k|0-9]
I need help to see what is wrong with the code. The application I need to use only uses PCRE.
Thank you.
You may use
^(\d{1,3}(?:\.\d{1,3}){2}-[\dkK])$
to match and capture (that is not usually necessary, but your app requires a capturing group to extract its contents) a whole string that matches the pattern. See the regex demo.
To match shorter strings that match this pattern inside a larger string, you may remove ^ and $ (see demo) or use \b word boundaries instead (see this demo).
Details:
^ - start of string
\d{1,3} - 1 to 3 digits
(?:\.\d{1,3}){2} - 2 sequences of a literal . and 1 to 3 digits
- - a hyphen
[\dkK] - a digit, k or K.
$ - end of string.
As they sometimes omit the dots, I used this one:
^(\d{1,2}(?:[\.]?\d{3}){2}-[\dkK])$
Details:
^ - start of string
\d{1,2} - 1 or 2 digits
(?:[.]?\d{3}){2} - 2 sequences of an optional '.' and 3 digits
- a hyphen
[\dkK] - a digit, k or K
$ - end of string
1234567-k OK
12345678-k OK
1.234.567-k OK
12.345.678-k OK
known issue:
12.345678-k and 12345.678-k still OK and I do not like this :(
You need to change to ^(\d{1,3}(?:\.\d{3}){2}-[\dkK])$ to capture only 2 sequence of 3 digits after the first sequence of 1-3 digits.
please consider being more specific in the REGEX build, since it matched wrong numbers, such as 17.87.335-2. Also the included one did't match formats without the dots or the hyphens.
Please consider using the following format: \b(\d{1,3}(?:(.?)\d{3}){2}(-?)[\dkK])\b
Modified prior version to try the other formats: https://regex101.com/r/2Us0j6/9
I'm fairly new to regex. I'm looking for an expression which will return strings in which the first character is of length 1, followed by an unlimited number of words of length 3 or more.
There should be a space between each word+.
So far I have:
([A-Za-z]{1,1} [A-Za-z+]{3,100})
As it stands this only returns phrases such as:
'I will' and 'A bird'
But I would like it to return phrases like:
'I will always try' and 'A bird flew into the cage'
Any help would be appreciated. I'm using an application called 'Oracle EDQ'.
You need to apply the limiting quantifier {3,} to the [A-Za-z] group and the * (zero or more repetitions) to the outer group matching a space + the 3+-letter words:
^[A-Za-z]( [A-Za-z]{3,})*$
See regex demo. Note the use of anchors ^ and $ that is very important when you need to match characters at a specific place (here, at the start and end of a word).
Regex matches:
^ - checks the regex engine is at the beginning of a string
[A-Za-z] - Exactly 1 letter a to z and A to Z
( [A-Za-z]{3,})* - zero or more sequences of...
- a space
[A-Za-z]{3,} - 3 or more ASCII letters
$ - end of string.
You can use this regex:
^[A-Za-z](?: [A-Za-z]{3,})+$
RegEx Demo