Advanced find and replace. Where do begin? - replace

I have an HTML page that has over 1500 of these links. The a href is wrong. How can I replace "images/image01.jpg" in this example with "fullsize/IMG_0028.JPG" repeatedly throughout the document. (the correct file name will always be in the same location).
<a href="images/image01.jpg">
IMG_0028.JPG
</a>

You can use a free editor like Notepad++ (http://notepad-plus-plus.org/) or Sublime (http://www.sublimetext.com/). Then click Ctrl+F or Ctrl+H (or simmilar) and choose the string to replace.

Related

how to add after img tag using regex cs6

I many files of pages which has images in. I need to add a </center> after each IMG tag. I'm using dreamweaver cs6 and I got this regex so far.
find <img [^>]+> and replace $&</center>
But it doesnt work. It finds and replaces the <img> tags ok but it doesn't add the </center>
Thanks in advance.
I dont know how this are done in dreamweaver, but to keep the "found" value you should add \1 - first regexp, \2 second and so on
\1</center>
or try $1 as in htaccess, but \1 is your best bet
Try this as your regex:
(<img [^>]+>)
and this as your replace string:
$1</center>
You need to add round brackets to create a capturing group which you can then reference with $1.
NOTE: Make sure you have changed the Search field to Source Code, deselected the Ignore whitespace and Match whole word checkboxes and selected the Use regular expression checkbox in the Find and Replace dialog.

get text between html tags correctly

I want to grab the text between html tags using Dreamweaver's search and replace tool.
The link format is a standard a tag e.g.
Text
Or:
Text and Text 2
Or:
Text
I am using the following expression:
(.*)
This works fine for example 1, but it picks up everything between the first opening tag <a href and the last closing tag </a> in the case of example 2.
What can I do to just targeting each individual link?
Also, what can I do in the case of example 3 where links also have a target="_blank" property?
if you just want the "Text" in the body of the tag
<a[^>]*>([^<]*)</a>
would work
if you also want the href
<a[^>]*href="([^>"]*)"[^>]*>([^<]*)</a>

Regular Expression, searching code in Dreamweaver

I just need to search some code and find the following, using the find and replace with regular expressions in Dreamweaver:
<div id ="specific_div"> anything can be in here </div>
I have not really tried to tackle regular expressions yet, but I am having trouble figuring out how to tell it that "I don't care what is in between the div tags, but please find me this specific div tag, everything in it and the closing div tag!"
There's a 'specific tag' option under the 'search' list in the 'Find and Replace' window. Why don't you use it? Anyway I'd probably use something like the following. But it won't select all the node if there's an idenatical closing tag <div> inside that div.
<div\b(.*?)(\bid)\s*=\s*("|')specific_div\3([\w\W]*?)</div>
I didn't close the opening tag because I thought you might have other attributes in that node. Oh and make sure the 'Match Case' option is not selected in the search window.

regex replace in dreamweaver

I'm trying to replace tags in my code, but keeping the text inside "as is".
example string:
<p class="negrita">text1</p>
or
<p class="negrita">text2</p>
i need to get those replaced as so:
<h3>text1</h3>
and
<h3>text2</h3>
i'm searching (and matching fine) with this,
<p class="negrita">([^>]*)</p>
but I have no idea on how to keep the text inside, as
<h3>$1</h3>
is not working.
Instead of using regular expressions to do this, use Dreamweaver's Specific Tag search option. While regular expressions are possible in Dreamweaver, it's a bit crippled and sometimes a little buggy.
To do this with Specific Tag, invoke the search using Control-F
Change the search option to "Specific Tag".
Next to that, enter p to search for all <p> tags
Hit the + icon below the box to add an option and select "With Attribute" "Class" "=" from the first three pulldowns and type "negrita" in the fourth.
For action, select "Change Tag" and then select h3.
Run this and you will get <h3 class="negrita">text1</h3>
Then repeat the steps above, searching for all h3 tags with the class negrita and choose Remove Attribute "class" for the action. Two steps to one, I admit but it will work every time.

Delete all lines until a specific line in Notepad++

I have to edit a lot of source codes similar to each other.
random blah
random blah
blah
<table style="width: 232px; font-size: small;" cellpadding="0" cellspacing="0">....
What I want to do is to delete lines until table tag. I think I can do it with Regex search but I couldnt write the regex pattern.
Thank you
You have to go through multiple steps to do what you stated above:
Go to the replace window, select the "extended" mode, and in the "find what" field type in "\r\n" and replace them with: "LINEBREAK" (theres a space after 'LINEBREAK'). Click on replace all.
Go to the replace window again, select the "regular expression" mode, and in the "find what" field type in "(.*)(.*)(<table)(.*)(>)(.*)(.*)" and in the replace with field, type in "\2\3\4\5". Click on replace all.
Now go to replace window again, select elect the "extended" mode, and in the "find what" field type in "LINEBREAK" (theres a space after 'LINEBREAK') and replace them with: "\r\n". Click on replace all.
Notepad++ doesn't support multi line regex, which makes it hard to do what you wanted to do without going through the steps given above.
you can try something like:
(^.*$\n)*<table(.+)>
First group will match all lines before your table tag %)