I have a code setup like this:
'olderVehicleHdr' : '#cft("We can still find you the right tires. Tell us what you drive.")#'
,'weCanStillHelpYou' : '#cft("We can still help.")#'
,'name' : '#cft("Name")#'
I need to switch the ' ' over to " " but there is A LOT of these in this file. and I'd rather not do each one individually so I thought I would try a regex setup. However I don't want the single quotes around the cft and ending # sign to be selected, since they need to be single quotes in order for the double quotes to work.
For example: I want to take 'name' : '#cft("Name")#' and turn the single quotes around name and make them double quotes like so: "name" : '#cft("Name")#'
This regex will be used on sublime to search for the appropriate characters and replace them. So my question is, can you make a regex that only selects the single quotes at the begining of the line and replace them? Without disturbing the second set of single quotes?
I've tried some of the lookbehind methods but they don't seem to work either. Any help would be greatly appreciated. thanks!
if sublimetext3 regex engine is based on PCRE use this pattern
'#cft[^']*'(*SKIP)(*F)|'
Demo
After a bit of tinkering, I have actually found a regex combo which seems to do the trick:
(?<![a-z]|\(|\\)'(?=[a-z]|[A-Z]|[0-1])|(?<=[a-z]|[0-9])'(?!\)) It's a tad bit sloppy but I only need it very rarely, and it works to me needs for right now. Thank you for your time to try and help me solve this!
Related
I'm upgrading a Symfony app with VSCode and I have numerous occurences of this kind of string :
#Template("Area:Local:delete.html.twig")
or
#Template("Group:add.html.twig")
In this case, I want to replace all the : with / to have :
#Template("Area/Local/delete.html.twig")
I can't think of doing it manually, so I was looking for a regular expression for a search/replace in the editor.
I've been toying with this fearsome beast without luck (i'm really dumb in regexp) :
#Template\("([:]*)"
#Template\("(.*?)"
#Template\("[a-zA-Z.-]{0,}[:]")
Still, I think there should be a "simple" regexp for this kind of standard replacement.
Anyone has any clue ? Thank you for any hint
You can use this regex with a capture group: (#Template.*):.
And replace with this $1/.
But you'll have to use replace all until there's no : left, that won't take long.
Just explaining a lit bit more, everything between the parenthesis is a capture group that we can reference later in replace field, if we had (tem)(pla)te, $1 would be tem and $2 would be pla
Regex!
You can use this regex #Template\("(.[^\(\:]*)?(?:\:)(.[^\(\:]*)?(?:\:)?(.[^\(\:]*)?"\) and replacement would simply be #Template\("$1/$2/$3
You can test it out at https://regex101.com/r/VfZHFa/2
Explanation: The linked site will give a better explanation than I can write here, and has test cases you can use.
I need a help with mass search and replace using regex.
I have a longer strings where I need to look for any number and particular string - e.g. 321BS and I need to replace just the text string that I was looking for. So I need to look for BS in "gf test test2 321BS test" (the pattern is always the same just the position differs) and change just BS.
Can you please help me to find particular regex for this?
Update: I need t keep the number and change just the text string. I will be doing this notepad++. However I need a general funcion for this if possible. I am a rookie in regex. Moreover, is it possible to do it in Trados SDL Studio? Or how am i able to do it in excel file in bulk?
Thank you very much!
Your question is a bit vague, however, as I understand it you want to match any digits followed by BS, ie 123BS. You want to keep 123 but replace BS?
Regex: (\d+)BS matches 123BS
In notepad++ you can:
match (\d+)BS
replace \1NEWTEXT
This will replace 123BS with 123NEWTXT.
\1 will substitue the capture group (\d+). (which matches 1 or more digits.
You could do this in Trados Studio using an app. The SDLXLIFF Toolkit may be the most appropriate for you. The advantage over Notepad++ is that it's controlled and will only affect the translatable text and not anything that might break the integrity of the file if you make a mistake. You can also handle multiple files, or even multiple Trados Studio projects in one go.
The syntax would be very similar to the suggestion above... you would:
match (\d+)BS
replace $1NEWTEXT
I'm currently cleaning up an XML file manually and removing unnecessary content and tags. It would help hugely if I could find all instances of a tag with its dynamic content and remove it with SublimeText Regex. How do I do this?
This is the tag that needs to be found. The content within the quotes is dynamic, which means I can't do simple find replace:
[simple_tooltip content='Colour Printer']
Is there a regex syntax that can help me kill the content within the quotes?
I've Googled a bit and haven't been able to find a clear way of doing this. However, regex is also confusing... Any help is greatly appreciated. Thanks
I don't use Sublime so this may be a little off, but I think you're looking for something like this?
Find content='.+?' Replace content=''
Explanation
Match content=' literally
Match . (any character) + (1 or more times) ? (lazily)
Match ' literally
I am currently using AutoHotKey, and I'm using lots of sub-functions. And so, in Notepad++, I would like to define a style for lines ending with ":".
An example of this situation would be :
FillGroup:
Gosub, GetID
Send, sometext {Down} {Enter}
Return
(FillGroup would be in blue, for example)
Even though I'm kind of a newbie to it, I tried some Regex in the Open delimiter section(I tried .+: and .+:$), but without conclusive results.
IMO, and until proven wrong, there is no (clean) way to do this since UDL 2.0 doesn't support regex.
You may brute force it by setting all the possible values of the opening within (( )) and separated by a space and the end with something like :((EOL))
I've been searching a lot in the web and in here but I can't find a solution to this.
I have to make two replacements in all registry paths saved in a text file as follows:
replace all asterisc with: [#42]
replace all single backslashes with two.
I already have two expressions that do this right:
1st case:
Find: (\*) - Replace: \[#42\]
2nd case:
Find: ([^\\])(\\)([^\\]) - Replace: $1$2\\$3
Now, all I want is to join them together into just one expression so that I can do run this in one time only.
I'm using Notepad++ 6.5.1 in Windows 7 (64 bits).
Example line in which I want this to work (I include backslashes but i don't know if they will appear right in the html):
HKLM\SOFTWARE\Classes\*\shellex\ContextMenuHandlers\
I already tried separating it with a pipe, like I do in Jscript (WSH), but it doesn't work here. I also tried a lot of other things but none worked.
Any help?
Thanks!
Edit: I have put all the backslashes right, but the page html seem to be "eating" some of them!
Edit2: Someone reedited my text to include an accent that doesn't remove the backslashes, so the expressions went wrong again. But I got it and fixed it. ;-)
Sorry, but this was my first post here. :)
As everyone else already mentioned this is not possible.
But, you can achieve what you want in Notepad++ by using a Macro.
Go to "Macro" > "Start Recording" menu, apply those two search and replace regular expressions, press "Stop Recording", then "Save Current Recorded Macro", there give it a name, assign a shortcut, and you are done. You now can reuse the same replacements whenever you want with one shortcut.
Since your replacement strings are totally different and use data that come not from any capture (i.e. [#42]), you can't.
Keep in mind that replacement strings are only masks, and can not contain any conditional content.