Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I need a regex which can search in the below string
Version updated to 13.0.1700.943 by the build system. NO_CI
Output needed 13.0.1700.943
Use this regex
(\d+\.){3}\d+
Breakdown
(\d+\.): This is the first capturing group. It finds one or more digits followed by a dot. Note that in regex, this dot has to be escaped.
{3}: This quantifier means, it will match the previous expression three times. In your example, you had three such instances
\d+: The last number does not have a dot after it, so we write it after the previous group.
Just to add to Richard Hamiltons answer (which would also match an IPv4)
the quantifier's can also limit the number of required places to match exactly your example
\d{2}\.\d\.\d{4}\.\d{3}
For a range you can use \d{1,2} to match one or two digits.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 months ago.
Improve this question
trying to find both "itchy" and "itching"
I can find just "itch" but id like to be able to code to find whole words.
^itch - obviously only finds root word
The \w in Wictor’s answer matches any alphanumeric character, that is, 0-9a-zA-Z. If you don’t mind having words like “itch8y” in your output result, you can use \w. Otherwise use [a-zA-Z] to only match pure alphabetic letters.
\b zero-width matches word boundary. The caret ^ you used matches beginning of line instead.
If it’s possible the word you’re looking for has capitalized first letter, better search for \b[Ii]tch[a-zA-Z]*\b.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I need to make a regex to validate an amount in which it only accepts numbers, points (.) Optional, 1 comma (,) optional and that after the comma I have at least 2 more numbers, the farthest I've come is this
^(([0-9]{0,})+([.]?))+([,]{0,1}?)([0-9]{1,}?)+$
This works fairly well, the problem is that it allows me to put the period (.) Followed more than once for example (100 ... 000), this accepts it, but I need it to only accept one period (.) At a time, how do i fix it?
I need the regex to validate as follows
100 VALID
100.000,00 VALID
100. INVALID
100..00 INVALID
100, INVALID
100..000,00 INVALID
To prevent the same character (in this case a dot) appearing consecutively, use a negative look ahead anchored to start of input:
^(?!.*[.][.])<rest of regex>
In your case:
^(?!.*[.][.])(([0-9]{0,})+([.]?))+([,]{0,1}?)([0-9]{1,}?)+$
See live demo with test cases from question.
I'm not clear on what you actually want to match, but I don't need to understand that to answer your question, which was how to prevent the same character appearing consecutively.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I'm looking for regex-way to find if a string matches any of this pattern:
2.
1.2
3.4.5
These numbers are taken from the numbering list of Word.
If you only want to match what is above, use ^((\d\.)+\d|(\d\.))$. (Link to regex tester).
This will either match that first kind of pattern (with a digit and then a period) or the other two, which have a digit followed by a period more than 1 time, and another digit at the end.
If you also want to match patterns like 3.4., i.e., strings that may or may not end in a period, you can use ^(\d\.)+\d?$ (Link)
This matches patterns that have a digit followed by a period one or more times, and then maybe a digit after that.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I need to capture something until a , (comma).
Example payload1: AgentBrand: Internet Explorer,
Example Payload2: AgentBrand: OutlookPlug-in,
From the above payload I need to capture whatever coming after AgentBrand:
until the command (,).
I have Tried AgentBrand:\s+(\w+\s+\w+) .But this will be become a lengthy regex.
Thanks
The current regex that you are using - AgentBrand:\s+(\w+\s+\w+) will only catch cases where you have at least two words separated by a space and even in those cases it will only pick up the first two words (when there may be more).
A better regex to use would be - AgentBrand:\s*(.*?),
what this does is
AgentBrand: - looks for the string 'AgentBrand:'
\s* - matches zero or more space characters
(.*?) - captures any characters non-greedily [takes minimum matches to satisfy result]
, - looks for a comma at the end
Also as a note, the length of a regex is not always a good reason to avoid using one. The regex in your example is not that long and is quite simple and could be freely if it met all your requirements. Looking at the complexity of a regex is a better choice
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am working on an online dictionary.
Currently I have all of my entries contained in a data array.
Example: "WORD ENTRY IN ONE LANGUAGE the same word in another language"
What I want to do is select all of the uppercase characters until the first next non-capital letter (may be a number, may be a parenthesis, etc., but is generally a lowercase letter).
I am currently trying to use a regex, but I have not had any luck!
Match all leading (anchored to start) uppercase letters and the space:
^[A-Z ]+
This simple expression will work in every regex flavor I can think of.
To not match trailing space(s) of the target:
^[A-Z ]*?(?= *[^A-Z])
If the regex flavor is C#:
^\p{Lu}+(?:\s+\p{Lu}+)*\b