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 am having the following String
{'Sample': '#it{tq}', 'Yield': 0.011063753491221462, 'Error': 0}
and I would like to extract the value from 'Sample', that means '#it{tq}'. I tried that using a regular expression: 'Sample':(\s*.+?\s)
but its giving me: '#it{tq}', including that comma at the end. Does anyone know how to erase the comma at the end?
this regular expression should do the job.
regex: 'Sample':\s*('[^']*')
https://regex101.com/r/DL5Ltq/2
how about using this:
'Sample': '(.*?)',
beware that the regex in the accepted answer cannot process the case having single quote escape text inside the capture group like this: {'Sample': '#it'{tq}'}.
If you use (.*?), it greedily process any single character inside two single quote.
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 days ago.
Improve this question
I tried to capture file extension: get .m3u8 if my filename is ABC.m3u8 for example.
The regular expression I use:
\w+(^\.[A-Za-z0-9]+)
I cannot get the result as my expected if I don't remove hat(^) character. Please tell me why, thanks.
There are two issues with \w+(^\.[A-Za-z0-9]+) :
^ would match the beginning of the string
not anchoring it at the end would give false captures, such as .foo for abc.foo.mp3
Here is the corrected regex:
^[\w+\.]+(\.[A-Za-z0-9]+)$
Or simply:
(\.[A-Za-z0-9]+)$
Learn more about regex: https://twiki.org/cgi-bin/view/Codev/TWikiPresentation2018x10x14Regex
^means match the beginning of a line, rather than beginning with ., so adding ^ will not match.
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 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
Is there a RegEx to remove everything but digits and spaces in Notepad++?
I know there is one that removes only digits but i dont need that.
PS: I do not want the lines to be removed
Example:
11234123 alex-james
1412412 mmafsmasdas
After regex:
11234123
1412412
As the pattern use [^\d ]+. Almost what Poul Bak proposed, but change * into +, i.e. the sequence of chars to match should be non-empty.
There is no point in searching for an empty string and replace it with another empty string.
correction:
try this:
([^0-9| ]+)
this will surely work!!!
open the file in notepad++ press CTRL+H check the box with search mode regular expression and put in the above regex and click replace all
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 3 years ago.
Improve this question
Please help in below matter:
I would like to find character (in my case: --) and replace with other (in my case: zz, or **) but only inside html comments (<!-- -->).
Thank you in advance.
If the regex flavor supports the \G anchor, it is done like this
Global find with (<!--(?=[\S\s]*?-->)|(?!^)\G)((?:(?!--)[\S\s])*?)(--)(?!>)
replace with $1$2zz or $1$2**
If the \G anchor is not supported it can be done with a
callback.
Match the comment <!--([\S\s]*?)--> in a replace call,
then in callback replace any -- in group 1 with zz or **, return the new comment (possibly unchanged) to the original replacement.
Construct it like return "<!--" + newcontent + "-->";
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 6 years ago.
Improve this question
I have string :
/url?q=http://www.bbc.com/indonesia/berita_indonesia&sa=U&ved=0ahUKEwjhqsr6h73OAhVDu48KHTR1AKsQFghDMAs&usg=AFQjCNEv3lNjzDNxPjfpqOtOb0ApNzvCCA
I want to get the result like this :
http://www.bbc.com/indonesia/berita_indonesia
How can I do with using RegEx ?
Thanks
The first capturing group of the following expression will extract the part you want. \?q=([^&]+)
You can extract it with following regex:
/(http:\/\/.+)/
the first (and only) capturing group contains value of url.
Here you can see it in action and adjust for your prefferred language.
EDIT: this pattern will capture whole URL along with following query string. Do you need url with path and without query string?