EG something of the form: 12. or 1. or 143.
Thanks.
The following will match all of your examples, and should work with any regex implementation:
[0-9]+\.
This is it:
^\d+\.$
Related
I have a string
K9908098F, G2342D34324/ 234234323, 234-234-234; R324234
How to catch only 234234323 and 234-234-234 in VBA?
This [\d-]+ pattern grabs extra pieces
You are pretty close, just need to add borders: \b[\d-]+\b
Regex demo and explanation
Give this a try:
(\w+),\s+([\w-]+);
This will capture 234234323 in group 1 and 234-234-234 in group 2.
Not too elegant though but would work. Just a small addition to your regex.
[\d-]+[,;]
You can try this too,
[-\d]+(?=[;,. ])
Demo
I am having a hard time figuring out a regular expression that would evalute as follows:
(valid)
.123456
1.
1.123456
123456.1
(not valid)
123
0...
I tried the following tool but I am not having much luck. (https://www.regex101.com/)
Thank you!
You could use positive lookahead assertion based regex like below.
^(?=.*\d)\d*\.\d*$
OR
^(?:\d*\.\d+|\d+\.)$
DEMO
^(?!\.$)\d*\.\d*$
Try this.See demo.
https://regex101.com/r/vN3sH3/7
I am looking for a reg ex to parse codes that look like this:
TEDL 9V1J 5K1Y EQFF NSA1 CF4T 8NQU UZL1
I have this regex, which works, but I would be grateful to understand how to make it more concise.
[A-Z0-9]{4}\s[A-Z0-9]{4}\s[A-Z0-9]{4}\s[A-Z0-9]{4}\s[A-Z0-9]{4}\s[A-Z0-9]{4}\s[A-Z0-9]{4}\s[A-Z0-9]{4}
Thanks.
Add this \s[A-Z0-9]{4} regex into a non-capturing group and add {7} after that to make the pattern to repeat for exactly 7 times.
^[A-Z0-9]{4}(?:\s[A-Z0-9]{4}){7}$
OR
\b[A-Z0-9]{4}(?:\s[A-Z0-9]{4}){7}\b
DEMO
You can use refactory your regex to:
\b((?:[A-Z0-9]{4}(?: |$)){8})
RegEx Demo
(([A-Z0-9]{4})\s){7}([A-Z0-9]{4})
I am trying to write some form validation, I need one of the inputs to be 1-9999. I know nothing about regular expressions ( never used them before) and here is my first attempt
/^([1-9][1-9]|[1-9]|[1-9]\d|9999)$/
Does not seem to want to work, can anyone help me? Thanks!
Try the below regex,
^(?:[1-9][0-9]{3}|[1-9][0-9]{2}|[1-9][0-9]|[1-9])$
DEMO
This doesn't exclude zero, but /^\d{1,4}$/ should do the trick.
Try using this
^([1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9])$
To exclude zero values but include non-zero ones with leading zeros:
([1-9]\d{0,3})|(\d[1-9])\d{0,2}|(\d{2}[1-9])\d?|(\d{1,3}[1-9])
This Regex should not match numbers that start with 0 a part from 0
Regex: /^(?!(0\d))\d{1,4}$/
Regex (Exclude Zero): /^(?!(0))\d{1,4}$/
Test: https://regex101.com/r/zfCKel/2
100.
101.
102.
guys this is my text and i want to change like this:
<tag>100.</tag>
<tag>101.</tag>
<tag>102.</tag>
My RegEx is:
[0-9][0-9][0-9]\.
Replace with:
<tag>\1</tag>
But it does not work :(
I could not see the numbers and dot sign.
Thanks in advance
You need some (capturing) parentheses;
Re: (\d{3}\.)
Replace <tag>\1</tag>
You're missing the \. in your brackets. Try this $regex = ":[\d\.]+:".