Cannot use ^(hat) in parentheses regular expression [closed] - regex

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.

Related

Regex Logic - replace commas between two numbers with dots [closed]

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

How to remove comma at end of extracted value? [closed]

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.

Is there a Notepad++ RegEx to remove everything but digits and spaces? [closed]

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

regular expression usage with [word1][wor2] [closed]

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.

Regex to search for everything before a string, and after [closed]

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 like to search for everything before the string http://thepaperwall.com/wallpapers/ but not including that string.
I would also like to search for everything after .jpg but not including .jpg.
So my final string should look like this:
http://thepaperwall.com/wallpapers/cityscape/small/small_642331afcd78d0840485bb352d99b289b50e8467.jpg
How can I do this?
You can use look-behind and look-ahead to get a string position between 2 other strings:
(?<=http://thepaperwall.com/wallpapers/).*(?=\.jpg)
You need a non-capturing group:
(.*)(?:http:\/\/thepaperwall\.com\/wallpapers\/.*\.jpg)(.*)
Live demo