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 9 years ago.
Improve this question
I would use regex to select one changing number
For example in the following example I would select 12090343 that I could change
I use:
preg_match (/(?<=Dossier.N..)(.*)(?=-)/)
It works but it's not so clean I think because the number of spaces could change and so it will not detect the number any more
Dossier N° 11110144-001 Pvt du : 03/09/2013 à 7:16
It looks fine, but you could slightly clean it up by .not grouping the number and making it match digits:
(?<=Dossier.{0,3}N.{0,3})\d+(?=-)
Most regex engines can't handle look behinds of arbitrary length, so rather than using the simpler (but unbounded) expression \s*, you must use a limited length expression like \s{0,3} to allow "some" whitespace.
You can try the following expression:
/Dossier[^0-9]*\K([0-9]*)(?=-)/
Regex101 Demo
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 1 year ago.
Improve this question
Hello there can i have an hint about how should i write the regex code to search for the commas (,) in those values between the |'...'| pattern? i need to find the commas and replace with dots(.) , if there's a comma in there of course.
|'2,3'|;|'5,6'|;|'2,1'|;|'3'|;|'6,5'|;|'9'|;|'7'|;|'4,4'|;|'4'|;|'1,1'|
expected result:
|'2.3'|;|'5.6'|;|'2.1'|;|'3'|;|'6.5'|;|'9'|;|'7'|;|'4.4'|;|'4'|;|'1,1'|
the pattern can be also what i will write below depending on some input parameters that i am going to receive in my method:
|'2,3'|,|'5,6'|,|'2,1'|,|'3'|,|'6,5'|,|'9'|,|'7'|,|'4,4'|,|'4'|,|'1,1'|
expected result:
|'2.3'|,|'5.6'|,|'2.1'|,|'3'|,|'6.5'|,|'9'|,|'7'|,|'4.4'|,|'4'|,|'1.1'|
this why i need a pattern for this because i don't know if i will receive the string with (;) or (,) separating the values
thanks so much
Regex Pattern
Here is the pattern that you can use to search for the commas , between two numbers
(?<=[0-9]),(?=[0-9])
Regex Demo
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 have a pattern like [word1][wor2]. I want to replace to {#link word2|word1}, word1, word2 could be anything.
I am very bad on using regular expression. Could anyone help me use regular expression match the pattern and replace to new pattern.
Thanks in advance.
Try the following find and replace, in regex mode:
Find: \[([^\]]+)\]\[([^\]]+)\]
Replace: {#link $2|$1}
Demo
The uses the approach of capturing the two adjacent word in square brackets, and then replacing with the text you want.
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 8 years ago.
Improve this question
How to process search results using regex?
E.g., I have a file with many strings like AB.
I want to get: 'AB'.
The letters always differ.
So I would search for the regex pattern ^\w+\n and want to use the search result, let me use '$#' to depict it, to get '$#'.
Regex:
(?<=:)([^,]+)
REplacement string:
'$1'
DEMO
Just to clarify: You want 71:A,72:BC,73:ABD to become 71:'A',72:'BC',73:'ABD' right?
Do a find/replace in whatever language or program you are using:
Find: (\w+)
Replace: '$1'
This finds ANY multi-letter string in your file and puts ' around it. if you only want to do the ones with [number:string] you will need to use a look-ahead like (?=\d+:) in front of the (\w+). So the whole Find would then look like (?=\d+:)(\w+), similar to what Avinash Raj has posted.
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 8 years ago.
Improve this question
I have some URLs:
google.com
stack.bing.com
yahoo.com/text/4378
yahoo.com/65456/4378/76576
How to remove URL with more than 2 / characters? After removing, it only has:
google.com
stack.bing.com
How to do it with regular expressions?
In this link http://textmechanic.com/Remove-Lines-Containing.html, it has Enable regular expression search function. So, i want to use regular expression for it.
You can use this regex for matching URLs with less than 2 slashes excluding cases of http://example):
^(?!.*?\/[^\/\n]+\/).+$
RegEx Demo
Or you can inverse the regex for removal:
^(?=.*?\/[^\/\n]+\/).+$
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 8 years ago.
Improve this question
I'm searching for a pattern for matching numbers with hyphen at the end like this :
125,000-
1.234,567-
60,000-
Just try with following regex:
/\d[.,\d]*-/
Or even:
/\d([.,]?\d+)*-/
NOTE Aleš Krajník's answer is basically the same as the answer I finally came to, except that his uses non-capturing grouping (as captures are not required)... he should get the votes IMHO as he was first
Note that in the following answer I'm assuming that , comma is the decimal separator, and that the . point is the thousands separator (eg for European numbering).
I believe the following is "correct":
^\d{1,3}(.\d{3})*(,\d+)?-$
This matches eg:
1-
12-
123-
123.456-
123.456.789-
1,0-
1,01-
1,001-
1,0001-
123.456,01-
123.456.789,0001-
etc
But will not match eg
1234-
123,-
123.4-
123.1,001-
123.45-
1..1..1-
1.1.1-
1,1,1-
.,-
etc.
The exact regex should read: \d{1,3}(?:\.\d{3})*(?:,\d+)?-
Try something like this:
[0-9.,]+-
\d{1,3}(?:[,]\d{3})*- takes internationalisation into account. The one below allows strings like 1..9 to match, which really should not.