regex find and replace characters inside html comment [closed] - regex

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 + "-->";

Related

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.

Regex pattern to replace characters [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
The program contains text of this type:
A B Ccccc
A Ccccc
ACcccc
ABCcccc
I need only such text to remain:
Ccccc
I wrote a replacement function, but I just can’t pick up a pattern
How to make such a pattern?
No need for regex, nor VBA. It seems you simply are looking for the position of the last upper-case letter and then to extract from there:
Formula in B1 (with Excel O365):
=MID(A1,MAX(SEQUENCE(LEN(A1))*(EXACT(UPPER(MID(A1,SEQUENCE(LEN(A1)),1)),MID(A1,SEQUENCE(LEN(A1)),1)))),LEN(A1))
If you don't have Excel O365:
=MID(A1,MAX(ROW(A1:INDEX(A:A,LEN(A1)))*(EXACT(UPPER(MID(A1,ROW(A1:INDEX(A:A,LEN(A1))),1)),MID(A1,ROW(A1:INDEX(A:A,LEN(A1))),1)))),LEN(A1))
You probably need to enter as array through: CtrlShiftEnter
If you must go through VBA and regex then a pattern like:
[A-Z][^A-Z]*$

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

Replacing comma with a dot in Notepad++ [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 6 years ago.
Improve this question
I am using Notepad++ and want to replace a comma coming in between numbers with a dot.
Like in below text file:
00:00:00,166 --> 00:00:03,999
In this section we will look at
should be like below:
00:00:00.166 --> 00:00:03.999
In this section we will look at
Thanks
Try this:
Find:
(?<=\d),(?=\d)
Replace with:
.
Here is a screenshot. Make sure you select Regular Expression radio button (pointed to by arrow).
Regex:
(?<=\d) - Positive look behind for a digit char
(?=\d) - Positive look ahead for a digit char
Demo:
https://regex101.com/r/iw1XsV/1

A simple regex call to replace some text in Eclipse [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 7 years ago.
Improve this question
I need help with a really simple regex find/replace command for Eclipse. It'd be great if you could provide me with something to try.
I need to replace all occurrences of the text typeSingleton(*) ), with typeSet({ * } ).
Assume that inside brackets you may have letters, brackets, spaces, then:
Find: typeSingleton\(([a-z ]+(\([a-z ]+\))? ?)\)
Replace: typeSet({$1})
EDIT
Demo: https://regex101.com/r/dD0wK0/1