Can someone please help me with a regular expression.
I'm having trouble with even the start as I'm a regex absolute beginner and the tutorials aren't really helping as I'm not understanding it.
I've got a large amount of files with things like 'products.htmlcar' or 'products.htmlcar_paper' or 'products.htmlhome-decorative_air_freshener'
I'm trying to remove all instances in all my files of the words "'products.html" and replace them with just the text at the end of it and append html to it before the ending " ' " for example 'products.htmlcar' becomes 'car.html' or 'products.htmlhome-decorative_air_freshener' becomes 'home-decorative_air_freshener.html'
I have tried to do a few of the things I checked out like
\^'products.html
but sublime text is not searching for this correctly. I don't know whether my syntax is incorrect or something but it's really confusing me.
Thanks in advance.
Try this:
Find: products\.html(.*?)'
Replace: $1.html'
Use this if your strings are
products.htmlcar
products.htmlcar_paper
products.htmlhome-decorative_air-freshener
^products.html
if your strings have ' a
^'products.html
Related
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
Is there a way to capture the first word of a string and then replace all commas using the captured first word?
I have attempted a hundred ways without success. I must be missing something. Is there a simple way to set a variable with regex?
string example:
"somename",'2','3','4','11','22','33','44','etc...'
desired results:
"somename",'2'
"somename",'3'
"somename",'4'
"somename",'11'
"somename",'22'
"somename",'33'
"somename",'44'
"somename",'etc...'
I'm using notepad++ (v7.5.6) for this. Any help would be greatly appreciated.
An interesting problem... the best I could come up with inside notepad++ was this: Find ^([^,]+)(,.+)(,[^,]+)$, replace with \1\2\n\1\3. This will replace
"somename",'2','3','4','11','22','33','44','etc...'
with
"somename",'2','3','4','11','22','33','44'
"somename",'etc...'
Continual pressing of Replace will eventually give you the desired output.
Hopefully someone else can do better...
I've seen people asking stuff related to regex and i thought id ask my quesstion. I have a file with many lines like this:
374327711199385
and I need to make it to this per each line:
3743-277111-99385
It's a big file so can't do it manually. Any ideas on how to make it automatic with regex? Thanks so much!
To perform this, you need to search with this expression:
^(\d{4})(\d{6})(\d{5})$
And replace with this:
$1-$2-$3
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!
I have to deal with a problem and maybe you can help.
I took over a Website with a lot of code and would like to have it run on PHP 5.4.
But there are a LOT of statement's like this:
if($arrayname['keyname']>"") ....
I would like to replace them all with:
if(!empty($arrayname['keyname'])) ....
Doing it manually will take forever :-(
Do you know how to use Dreamweaver's CS5 search & replace with RegEx capabilites - unfortunately my RegEx knwoledge is limited.
Of course the regex must be "variable, as the arrayname and the keyname always changes.
Any help on finding the correct RegEx Stamtent is HIGHLY appreciated .
Regex to find all occurrences of if($arrayname['keyname']>""), whatever arrayname and keyname are, if only letters :
if\\(\\$[a-zA-Z]*\\[\'[a-zA-Z]*\'\\]>\"\"\\)
You'll have to find how to use BackReferences in Dreamweaver. If it uses standard Regex, then use the tutorial in the link, it will be of great help for you.
To complete and close this question:
In Dreamweaver search for (Regex Search in Code):
if\(\$(\w+)\[['"](\w+)['"]\]>""\)
Replace by:
if(!empty($$1['$2']))