Can any one tell me regular expression that no. should start with:
0300
0500
0800
0808
I am using this but it is not working
(0800|0300)\d
You can use this:
0[358]0[08]\d*
If you are looking for only one such number on each line in a file, you can use this:
^0[358]0[08]\d*$
0[358][08]\d*
should work. What doesn't work for you?
Related
I'll try and make this concise.
I want to only capture the string within the parenthesis of:
background-image:url()
I've tried for hours and the best I could come up with was (?<!\#\*)(?<=url\().*(?=\)).
(Try it online)
This is almost perfect except when there is a run on line like this or any minified CSS code:
background-image:url(/images/products/test#2x.png);height:0;background-image:url("/images/products/test#2x.png")
It captures everything from the first open parentheses to the last closed parenthesis including the irrelevant styles in between.
I only want to capture the string between the url()'s.
Using positive and negative lookbehind: /(?<=background-image:\s*url\().*(?=\))/ig will return everything inside the background-image: url() call, with \s* to catch spaces.
use regex
(?<=background-image:url\()(.+?)(?=\))
can found all xxx in background-image:url(xxx), while not include background-image:url()
you can check result in: https://regexr.com , like this:
Note:
about look around = look ahead and look behind, here is my summary:
more detail can refer (Chinese) tutorial: 环视断言 · 应用广泛的超强搜索:正则表达式
Below is the regex which will work for you:
(?<!\#\*)(?<=url\().*?(?=\))
Hope this helps!
I have a statement like Data lva_var type Integer value 20. I need to find out the token after type.
My latest try was [type](?:\s\S+), but the match was e integer.
Code snippets would be helpful.
Just try this, type\s(\w+)Here the first group contains the word next to "type"Hope this code helps.
You can use lookbehind for this (?<=\btype\s)(\w+) will do the trick for you. Take a look at this example.
JavaScript doesn't support lookbehinds, but since you tagged nsregularexpression and that does support them, maybe try this: (?<=\btype\s+)\w+
I tried with the following regular expression but it is not working as expected.
/^([01]?[0-9]|2[0-3]):[0-5][0-9]{2}(AM|PM)/
You can try using this regex:
^(0?[1-9]|1[012])(:[0-5]\d) [APap][mM]$
REGEX DEMO
You can try like this
/^[1-12]:[0-59](A|P)M$/i
You are missing space before AM|PM and there is unnecessary {2}
The following changes works for me:
^([01]?[0-9]|2[0-3]):[0-5][0-9] (AM|PM)
On the string
09:15 AM
I want to know how can I get a regular expression for matching number, ., and - only.
I am using this:
/^[0-9\.'S]+$/
by this it working fine but not working for symbol "-".
You simply haven't used the literal dash - (or minus) in the regex. Try:
/^[0-9\.-]+$/
But if you want a proper number, you might want to use a more proper regex:
/^-?[0-9]+(?:\.[0-9]+)?$/
The first regex can accept things such as 3987----.... while the second will not accept it, but will accept things like -87.983274.
That's because - is not part of your character class. You are only using - in the class range (which only includes digits). Also, I don't know what the S and the ' are doing there:
/^[0-9.-]+$/
Also, I can promise you that after taking the time to read through this tutorial regular expressions will seem a lot less confusing to you.
Try the below regex.
/^-?[0-9\.]+$/
I am newbie in Regular Expressions.
I need to check this time 18:00(00:00, 01:00, 05:12, any time of this format) by regexp, is it correct or no.
Here is my variant:
/[0-9][0-9]:[0-9][0-9]/
Can I change [0-9][0-9] to something like 2*[0-9] ???
If you specifically want to match 18:00 you should use /^\d{2}:\d{2}$/. The answers provided so far will match aaa12:99ddd. The ^ and $ are anchors and will instruct the regex to match specifically the given string.
If you are after a 24 hour validation regular expression you could use this: /^([01]?[0-9]|2[0-3]):[0-5][0-9]$/ (taken from here).
You can also write it like this: /^\d{2}:\d{2}$/
You can modify it by adding a repetition clause:
/^[0-9]{2}:[0-9]{2}/
But you should add the starting and ending clauses :
/^[0-9]{2}:[0-9]{2}$/