I need to find and replace the text [n] with the text \textsuperscript{n}.
Where n is a number between 1-99.
EG. the text [15] with the text \textsuperscript{15}
I am not a programmer but think grep is my friend here.
I have tried:
Find: \[\d+\]
Replace: \\textsuperscript{\d+}
this finds the numbers but replaces them with \textsuperscript{\d+} (predictably).
Where am I going wrong please?
Thanks for your help.
Found the solution over on Google Groups for Textwrangler. Apparently I needed a subpattern.
Find: \[(\d+)\]
Repalce: \\textsuperscript\{\1}
Here is a link to the Solution
Thanks for your help. Found the solution over on Google Groups for Textwrangler. Apparently I needed a subpattern.
Find: \[(\d+)\]
Repalce: \\textsuperscript\{\1}
Here is a link to the Solution
Related
I am trying to do an advanced text search and replace in a text editor (I can use SublimeText or VSCode)
Input:
parameters['myParameter1']
parameters['myParameter2']
Expected output:
myParameter1
myParameter2
And I have hundreds of similar scenario in the file. So that's why I'm thinking of using regex to solve this.
Thanks
Hope this will help you out.
Regex demo
Regex search: parameters\['([^']+)'\]
1. parameters\[' this will match parameters[' Optinally if you have other keywords then parameters and which can be dynamic for that you can use [a-zA-Z]+ this will include all lower case and upper case.
2. ([^']+) this will match all except ', () will capture first match in $1.
3. '\] this will match ending ']
Replacement: $1
Note: If you are using gedit ubuntu you have to replace it with \1
VSCode can search all files in a directory, and it supports RegExp too!
Use ctrl+shift+f to search all files, hit the .* icon for RegExp.
A search expression such as parameters['(.*)'] replaced with $1 should work!
Check out the official guide for more info: VSCode Basic Editing
I have this:
1200
3701
Trying to get this:
100ct1200
100ct3701
But got this:
100ct([0-9])([0-9])([0-9])([0-9])
Because I used regex in find & replace:
Find: ([0-9])([0-9])([0-9])([0-9])
Replace: 100ct([0-9])([0-9])([0-9])([0-9])
Actually I don't know how to express it to just add 100ct infront of the numbers and leave the rest as-it-is. Help? Thanks!
You need to use the following syntax
Find: (([0-9])([0-9])([0-9])([0-9]))
Replace: 100ct\1
Note the parentheses around the whole find expression: \1 refers to their content.
EDIT:
You can also use some shorthands for the Find expression:
Find: (\d{4})
It means "match 4 digits".
Your find and replace commands should be,
Find: ([0-9][0-9][0-9][0-9])
Replace: 100ct$1
$1 or \1 or #1 according to your tool.
Find: ([0-9][0-9][0-9][0-9])
Replace: 100ct$1 or 100ct\1 depending on the language (not sure what syntax Notepad++ uses).
Demo: http://regex101.com/r/cT1mJ8/1
I am looking for a solution to find and replace the formatting of many prices within one of my documents.
I currently have prices that are formatting like so: $60 and would like to change the formatting to: 60 $
The following 'Find What' works to find the first format \$\d{0,2} but not too sure about what to 'Replace With'.
Is there a way to preserve the number?
Thank you.
Try this:
find: \$(\d{0,2})
replace: \1 $
Option+Cmd+F:
Place into the find field:
\$([0-9]{0,2})
Place into the replace field:
\1 \$
The backslash + number indicated which capture group to place in there.
Sorry for not knowing the basics of regular expressions and asking this, but I couldn't get to it myself.
I need to replace all expressions PlayerTextDrawSetString(SSbank[playerid],strBank)
with PlayerTextDrawSetString(playerid,SSbank[playerid],strBank)
,
PlayerTextDrawSetString(SWant[someid],strWant)
with PlayerTextDrawSetString(someid,SWant[someid],strWant)
etc.
I can find such expressions with PlayerTextDrawSetString+\(+.+\[+.+\], but I can't replace them with that (\1, \2, \3 etc. return empty symbol).
I tried different search strings, but in all cases I get nothing on \1, \2, etc.
Could you please write the correct regex for me?
Thank you in advance for the help.
Try these expressions:
Search:
(PlayerTextDrawSetString\()(\w+\[)(\w+)
Replace:
\1\3,\2\3
The first two examples work.
Search Pattern 1:
SSbank\[([^\]]+)\]
Replacement Pattern 1:
\1,SSbank[\1]
Search Pattern 2:
SWant\[([^\]]+)\]
Replacement Pattern 2:
\1,SWant[\1]
To go all out if you have a lot of these similar patterns you can do this:
Total Replacement Search:
\((\w+)\[([^\]]+)\]
Total Replacement String (yes the first slash is needed... a bug maybe?):
\(\2,\1[\2]
Look behind is apparently broken.
I tried to give Notepad++ a shot with the positive look behind but the replacement fails even though the match happens. Here's the pattern:
(?<=\()(\w+)\[([^\]]+)\]
My attempted replacement (doesn't replace anything in Notepad++ v6.3.2):
\2,\1[\2]
If we have the following lines
<something>A<else>
<something>B<else>
<something>C<else>
Using regular expressions in Notepad++ how to remove all and keeps the letters to be
A
B
C
I've used to replce (.*)(>)(.*) by \3 but didn't worked so anyway what would be the command if i want remove all (things) before (something) and all (things) after.
Thanks
Dear Manal Nor, welcome to Stack Overflow!
I achieved the above result using the following code in Notepad++ 5.6.8:
"FIND WHAT":
<[^>]+>([^<]*)<[^>]+>
"REPLACE WITH":
\1
Let me know if it works!
try search ^.*>(.*)<.*$ and replace \1
I don't have the program here but try something like replacing
.*>(.*)<.*
with
\1
I went with:
(<.*>)(.*)(<.*>)
\2
and that seemed to work for me.
or just
<.*>(.*)<.*>
\1