How to do this find and replace?

I have been trying to figure out the regex for this find and replace (I thought it would be easy!), but my frustration is getting the better of me and any help would be greatly appreciated.  I'm trying to do two find and replaces:
1) In the first, I'd like to find:
</script>
XXXX
</head>
where XXXX are always four letters (uppercase) and I want to store the four letters as a variable ($1) to use in the replace
I'd like to replace this with a bunch of javascript and in the middle of the script, I'd place the variable referencing these four letters (<script type="text/javascript">var blah = new Spry.Data.XMLDataSet("http://$1.com"blahblah</script></head>
2) The second find is similar:
</html>
XXXXXXXX
where once again X are 8 letters in uppercase following the close of the html tag (this has resulted from previous find and replaces and now I'm trying to correct things)
I simply want to delete these letters in this case (so will leave the replace blank).
Any help is greatly appreciated!  Thank you

Having 46 people view a post without replying is not unusual. Some people look at a question to see if it's something they'd like to know the answer to, and then come back  when it has eventually been answered.
I'm not sure if you need to escape forward slashes in Dreamweaver's Find and Replace dialog box, but I normally do because both JavaScript and PHP normally use forward slashes as delimiters to mark the beginning and end of the regex like this:
var pattern = /[A-Z]{4}/; // JavaScript
$pattern = '/[A-Z]{4}/';   // PHP
When a forward slash appears inside the regex, you need to escape it with a backslash to avoid confusion with the closing delimiter.
As you have worked out, a capturing group is created by wrapping part of the regex in parentheses.
If you want to match exactly 38 characters, you can use [\S\s]{38}. That includes spaces, newline characters, symbols, everything.
If you're trying to find everything between two tags, you can do this:
(<\/tag_name>)([^<]+)
The closing tag is captured as $1 and everything up to the next opening tag is captured as $2.
Learning regular expressions is not easy. I don't claim to be an expert, but I enjoy the challenge of trying to solve them. If you're interested in regular expressions, there are several books published by O'Reilly. "Mastering Regular Expressions" is the ultimate authority, but it's a difficult read (not because it's badly written, but because of the complexity of the subject). "Regular Expressions Cookbook" is very good. There's also a new "Introducing Regular Expressions", but I haven't read it.

Similar Messages

  • How to edit the find-and-replace dialog in Dreamweaver 8

    For over 13 years I have been a happy user of Macromedia Dreamweaver 8. And I still see no reason to use any other program for editting PHP.
    However, 1 thing has been bugging me for years. In the find-and-replace dialog there is a select "Find in". The options are in a dropdown.
    I want this select to be a multiselector (not in functionality, but just so I don't need to click to get the dropdown, but just one click to select).
    I read in the help at 'Customizing the appearance of dialog boxes' at point 4
    On your disk, find the appropriate HTM file in the Configuration/Objects, Configuration/ Commands, or Configuration/Behaviors folder.
    I've been searching but can not find the code for that dialog, althou it should be easy. Also did a search for that 'save' image, because once I find that, I can find this form, but its not in the macromedia folder.
    how to edit the find-and-replace dialog in Dreamweaver 8?

    It's looks less like an image and more like a form drop list to me.
    Yes its a dropdown list. But to find the code for that select I tried to find the htm file that code is on by searching for the save-image which is also on that page (next to the yellow folder). I did a search on all folders in c:/programfiles/macromedia and that image is not in there. If I could find the image name, I could search the code for that and should find that htm (or javascript) which is outputting it, then the select must be near to that.
    I also searched the code for the various texts on the page and got many hits, but not from the dialog page. I can't search dll files, so maybe thats where that code is in.

  • How can I multi-find and replace relative paths to external topics?

    I am using RH7 and publishing to a company server share. External topics are saved on the same server share and linked on my local drive to create a relative link. How can I do a multi-find and replace on the relative links to change the path to the external docs? The paths do not show up in the Topics List because they are relative, not absolute. Although changing all of the many paths manually would be job security, I would like an easier fix. Thanks for any help.

    Hello again
    Likely your best bet at this point is to use a good Multi-File Find and Replace utility.
    While RoboHelp has one included, it often fails. So we typically recommend something like FAR (Find And Replace) or BKReplace.
    Click here to visit the FAR site
    Click here to visit the page for BKReplace
    Cheers... Rick
    Helpful and Handy Links
    RoboHelp Wish Form/Bug Reporting Form
    Begin learning RoboHelp HTML 7, 8 or 9 within the day!
    Adobe Certified RoboHelp HTML Training
    SorcerStone Blog
    RoboHelp eBooks

  • How to do a "Find and Replace" only on html or htm documents

    I am trying to add some Java script to every page in a website that is a html or htm before the </body> tag.
    The site contains other file types and the find function is ofcourse picking those up as well. Since the site has over two-thousand pages it would be very labor intensive to click through them all.
    Any ideas would be very helpful.

    I wouldn't be worried about anything but the *.sql files.  If an asp or aspx file matches that tag pair, then you would want to add the analytics code anyhow.
    Nevertheless, the only other way I can think of to do what you want would be to sort the file list by type, and select only the *.html and *.htm files before running the find and replace against the selected files.

  • How to perform a find and replace of Portal content?

    We recently changed the URL of a business application and I would like to replace the old URL with the new URL in all Portal content items, including URL item types, Text item types, item descriptions, HTML Builder portlets, etc...
    I can use the Portal's built-in search to find most instances of the old text, but can I perform a SQL query to replace the existing text fragment with a new text fragment?
    TIA

    This is script, we use when we refresh test environment from production. Change variables values as per your setting under define ...
    login as portal
    set echo on
    set term on
    spool changeurl.log
    define PROD_DN=prodhost
    define DEV_DN=devhost
    define PROD_HOSTNAME=prodhost.hsys.local
    define PROD_PORT=7778
    define DEV_HOSTNAME=devhost.hsys.local
    define DEV_PORT=7780
    update wwsec_group$
    set dn=replace( dn, '&&PROD_DN', '&&DEV_DN' )
    update wwsec_group$
    set dn_hash = wwsec_api_private.get_dn_hash( dn )
    -- users (dn)
    update wwsec_person$
    set dn=replace( dn, '&&PROD_DN', '&&DEV_DN' )
    update wwsec_person$
    set dn_hash = wwsec_api_private.get_dn_hash( dn)
    -- subscriber
    update wwsub_model$
    set dn=replace( dn, '&&PROD_DN', '&&DEV_DN' ), GUID=':1'
    where dn like '%&&PROD_DN%'
    -- preferences
    update wwpre_value$
    set varchar2_value=replace( varchar2_value, '&&PROD_DN', '&&DEV_DN' )
    where varchar2_value like '%&&PROD_DN%'
    update wwpre_value$
    set varchar2_value=replace( varchar2_value, '&&PROD_HOSTNAME:&&PROD_PORT', '&&DEV_HOSTNAME:&&DEV_PORT' )
    where varchar2_value like '%&&PROD_HOSTNAME:&&PROD_PORT%'
    -- page url items
    update wwv_things
    set title_link=replace( title_link, '&&PROD_HOSTNAME:&&PROD_PORT', '&&DEV_HOSTNAME:&&DEV_PORT' )
    where title_link like '%&&PROD_HOSTNAME:&&PROD_PORT%'
    -- web providers
    update wwpro_providers$
    set http_url=replace( http_url, '&&PROD_HOSTNAME:&&PROD_PORT', '&&DEV_HOSTNAME:&&DEV_PORT' )
    where http_url like '%&&PROD_HOSTNAME:&&PROD_PORT%'
    -- html links created by the RTF editor inside text items
    update wwv_text
    set text=replace( text, '&&PROD_HOSTNAME:&&PROD_PORT', '&&DEV_HOSTNAME:&&DEV_PORT' )
    where text like '%&&PROD_HOSTNAME:&&PROD_PORT%'
    -- Portlet metadata nls: help URL
    update wwpro_portlet_metadata_nls$
    set help_url=replace( help_url, '&&PROD_HOSTNAME:&&PROD_PORT', '&&DEV_HOSTNAME:&&DEV_PORT' )
    where help_url like '%&&PROD_HOSTNAME:&&PROD_PORT%'
    spool off

  • How to use Microsoft Word's Find and Replace with HTML tags?

    Hello to all!
    I'm trying to figure out how to use the find and replace function in Word to replace html tags. I'd like to be able to change something like this:
    <span class="B01-K-ITAL">random text</span>
    To something like this:
    <em>random text</em>
    I want to replace the open and close tags without changing or interfering with the text between the tags. I'm pretty sure I should use wildcards, but I can't figure out how to use them properly.
    Anyone able to lend a hand?

    Here is my latest regular expression with Perl.   I think it matches the spirit of the request in the original post.
    Note, this isn't as easy as you think.  You need to code up the complete set of html rules in you implementation. You need to allow for a certain amount of mal-formed html.
    perl -0660pe 's^<[sS][pP][aA][nN]\s+class="B01-K-ITAL"\s*>(.*?)</[sS][pP][aA][nN]>^<em>$1</em>^gs' i.html >|o.html
    input text
     <html> <head>...</head> <body>I'd like to be able to change something like this: <span class="B01-K-ITAL">#1 one line</span> I want to replace the open and close tags without changing or interfering with the text between the tags. I'm pretty sure I should use wildcards, but I can't figure out how to use them properly. <p>note, this isn't as easy as you think.  You need to code up the complete set of html rules in you implementation. You need to allow for a certain amount of mal-formed html.</p> <span class="B01-K-ITAL">#2 don't be greedy</span> <span class="B01-K-ITAL">$3 multiline text</span> <span class="B01-K-ITAL">#4 multiline tag. I believe html allow a carriage return in white space of tags</span> <span class="B01-K-ITAL">#5 split after the class tag. optional white space</span> <sPan class="B01-K-ITAL">#6 mixed case tag</Span> <p>no text #7</p><span class="B01-K-ITAL"></span> <!-- Apparently, this is valid     http://www.positioniseverything.net/articles/cc-plus.html --> <!--[if IE]> <div id="IEroot"> <![endif]--> <p id="IE">This browser is IE.</p> <p id="notIE">This browser is not IE.</p><!--[if IE]> </div> <![endif]--></body> </html>
    output text
     <html> <head>...</head> <body>I'd like to be able to change something like this: <em>#1 one line</em> I want to replace the open and close tags without changing or interfering with the text between the tags. I'm pretty sure I should use wildcards, but I can't figure out how to use them properly. <p>note, this isn't as easy as you think.  You need to code up the complete set of html rules in you implementation. You need to allow for a certain amount of mal-formed html.</p> <em>#2 don't be greedy</em> <em>$3 multiline text</em> <em>#4 multiline tag. I believe html allow a carriage return in white space of tags</em> <em>#5 split after the class tag. optional white space</em> <em>#6 mixed case tag</em> <p>no text #7</p><em></em> <!-- Apparently, this is valid     http://www.positioniseverything.net/articles/cc-plus.html --> <!--[if IE]> <div id="IEroot"> <![endif]--> <p id="IE">This browser is IE.</p> <p id="notIE">This browser is not IE.</p><!--[if IE]> </div> <![endif]--></body> </html>

  • How do I find and replace text in PHP files?

    How can I in CS3 make sitewide changes to the text in PHP pages without changing variable names etc that have the same name?
    For example if I have an installation of a PHP forum and I want to change every instance of the word 'forum' to 'message board'...
    If I used the 'inside tag' search with " as the tag, then if "" contained a variable called 'forum' it would also be changed and therefore corrupt the code....
    Is there a simple way around this?
    Thanks!
    I'm using CS3 on Windows Vista.

    It looks like you're trying to find and replace source code, so you may be able to look at the various places that are looked at when finding and uncheck the ones that don't apply.
    But, if it's all source code then that won't help.  One thing that may work is to expand the search option - for example if the work "forum" that you're wanting to change it preceded by another word, or character or something that sets it apart, then do you find on that. You can expand that search phrase as far out in either direction that you need to to make it different, if of course that is practical in your situation.
    The only other way I can think of is to somehow create an exception rule, but I'm not sure if that's possible or how to do it.

  • How do I create a multiple find and replace for Excel in AppleScript?

    I have a large dataset in Excel that I have to do a multiple find/replace in (changing USPS state abbreviations to their full names). In searching the Microsoft boards--I was directed to use Applescript, and even the documented help with Excel was recommeding this. Unfortunately, there wasn't much help potinting me in the specific direction I needed. Any ideas on how I should write this script?
    Thanks!

    I'm confused as to why Applescript (or any script would be helpful).
    You'd have to type the abbreviation and the full name into the script, the same as just using Find and Replace All. You wouldn't gain anything by using a script. Is there more to this task than you've let on?
    MacTech has an article on converting from VBA to Applescript, but I'm not sure if it would have any ideas on your specific problem: http://www.mactech.com/vba-transition-guide/index-toc.html

  • How do I find and replace a word in PDF?

    How do I find and replace a word in PDF?

    In the Find window (Ctrl+F) there's an option to replace the searched text.
    This is in Acrobat XI, and there's no Replace All-function.
    On Thu, Jan 15, 2015 at 4:27 PM, claireb88184899 <[email protected]>

  • How to find and replace text in Excel with Automator

    I am new to Automator. And I would like some help how I can create a service that will allow me to find and replace certain text in Excel. I noticed that there is an action to do this for Word documents, but not for Excel document.
    Any suggestions how I can do this?
    Thanks so much for your help.

    Easiest way to do it is the following:
    - Open the PDF file in Acrobat.
    - Go to Tools - Forms - More Form Options - Export Data.
    - Save the form data as an XML file somewhere on your system.
    - Open XML the file in a plain-text editor (I recommend Notepad++).
    - Let's say you want to replace all the years in the dates from "2013" to "2014". Do a global Search&Replace of "2013-" to "2014-" (I added the dash just to make sure that only date fields are edited).
    - Save the XML file (maybe under a new name).
    - Go back to the PDF file, and now go to Tools - Forms - More Form Options - Import Data.
    - Select the edited XML file and import it.
    - Done!

  • How do you find and replace "within selected text" in a textedit document (version 1.8, mountain lion)

    In the textedit version on Snow leopard it was possible to search and replace within a peice of selected text only i.e. not the entire file. This was a very useful feature because you could select a paragraph and replace all occurences of word1 with word2 within that paragraph only! This feature appears to be missing from the mountain lion version of textedit (version 1.8). Or can anyone tell me how to do it ... ?

    Having 46 people view a post without replying is not unusual. Some people look at a question to see if it's something they'd like to know the answer to, and then come back  when it has eventually been answered.
    I'm not sure if you need to escape forward slashes in Dreamweaver's Find and Replace dialog box, but I normally do because both JavaScript and PHP normally use forward slashes as delimiters to mark the beginning and end of the regex like this:
    var pattern = /[A-Z]{4}/; // JavaScript
    $pattern = '/[A-Z]{4}/';   // PHP
    When a forward slash appears inside the regex, you need to escape it with a backslash to avoid confusion with the closing delimiter.
    As you have worked out, a capturing group is created by wrapping part of the regex in parentheses.
    If you want to match exactly 38 characters, you can use [\S\s]{38}. That includes spaces, newline characters, symbols, everything.
    If you're trying to find everything between two tags, you can do this:
    (<\/tag_name>)([^<]+)
    The closing tag is captured as $1 and everything up to the next opening tag is captured as $2.
    Learning regular expressions is not easy. I don't claim to be an expert, but I enjoy the challenge of trying to solve them. If you're interested in regular expressions, there are several books published by O'Reilly. "Mastering Regular Expressions" is the ultimate authority, but it's a difficult read (not because it's badly written, but because of the complexity of the subject). "Regular Expressions Cookbook" is very good. There's also a new "Introducing Regular Expressions", but I haven't read it.

  • How can i find and replace xml tags?

    Hi, i am using xml in my workflow and want to be able to remove certain tags if they contain particular text.
    here is an example of my xml structure…
    <entry>
        <name>DEFAULT</name>
        <tel>DEFAULT</tel>
        <address>DEFAULT</address>
    </entry>
    I am using this initial structure to set the paragraph styles to be followed when the xml data is imported.
    This leaves DEFAULT in place wherever an entry doesn't have any content for that field.
    I want to be able to import my XML then run a script that removes any tags that include DEFAULT, - I need the entire xml tag to be removed not just the text, if i do a normal find and replace it will only remove the text not the tags which is causing problems with styling. I also want to remove the end of para/return (^p) that i've placed at the end of the line. So it would be the same as opening up story editor and removing the content + tags + hard return in there, but i want to automate the process…
    So i think this is what i need to search for in each case
    "<name>DEFAULT</name>^p"
    and i want to replace it with nothing ""
    Can this be done through scripting (ideally javascript)?
    I have a little knowledge of javascript but am not sure how to search and target that kind of string in indesign...
    using indesign cs5
    many thanks

    Hi,
    Script should do it in two steps:
    1. find all occurences of i.e. ">DEFAULT<"
    2. remove whole paragraph which is a found_text's container.
    For example this way -JS - (a textFrame filled with your text should be selected) :
    var mStory = app.selection[0].parentStory;
    app.findTextPreferences =  null;
    app.findTextPreferences.findWhat = ">DEFAULT<";
    var myF = mStory.findText();
    var count = myF.length;
    while (count--)
         myF[count].paragraphs[0].remove();
    rgds

  • How to create mail merge(feature in word) in adobe pdf and programmatically find and replace these t

    I am very new to adobe.I am required to do the following and am very confused.The scenario is as follows:
    I am required to create a letter template (using adobe designer) where name and few other details will be tags(which needs to be replaced by actual values according to the particular customer later on).We can create such a feature in word using mail merge feature available there.How do we do the same in pdf??Can it be done using adobe designer 7.0???If so,how?
    After I create this template,I am required to write a javascript or a VB program to access this pdf template and find and replace these tags with the actual values and generate a pdf document.Somebody told me that this is to be done using adobe document server(ADS). Can this be done??If so,how?If not what is the alternative product in adobe?
    There are so many adobe products that i am totally at sea and not able to figure out which to use and how.
    Please help me at the very earliest.
    Thanks in advance.
    regards,
    Sowmya

    Let me thank u for a prompt reply but I guess I still need ur help before I accomplish what I set out to do.
    As per your reply I used Forms API in my vb program and it is accessing the fields but I am not able to change the property of the fields.
    I created the pdf form using adobe designer 7.0 and have created a floating field which I want to populate using my code.This is invisible in the pdf template but I when I set the value for it using vb code I need to change its property to visible.
    But when I try to change the "NoViewFlag" property, I get an error as follows:
    Runtime error'-2147220988(80040204)
    Document's Security Settings prohibit the operation being performed
    Please give your suggestions.
    2.Another question is how do I differentiate floating text field and ordinary text field in vb code because the type of both is displayed as text ??
    Thanks again.
    regards,
    Sowmya
    I am putting my code below for ur viewing.

  • How To: Find and replace multiple words in one Click ?

    I have an file with about 150 Pages where I want to replace a word about 500 time by one click.
    Find and Replace works but only with one word.
    How can I do it by one click ?

    You can't, not in Acrobat anyway.
    This is the kind of thing that should be done in the original file format,
    not in a PDF.

  • How to find and replace certain text in Excel.

    I am new to Automator. And I would like some help how I can create a service that will allow me to find and replace certain text in Excel. I noticed that there is an action to do this for Word documents, but not for Excel documents.
    Any suggestions how I can do this?
    Thanks so much for your help.

    Marga,
    I think the best place to ask about Office for Mac would be in the MS forums.
    Jerry

Maybe you are looking for

  • Error of Control Framework

    Hi All, I am passing input data to RFC,  In input parameters I am passing data to three import parameters and one table parameter of RFC from Web Dynpro. Once I execute it, am getting error "Error in Control Framework,  error key : RFC_Error_System_F

  • Indesign 2014 - data collection

    Hello, in indesign 2014 CC doesn't work data collection. It starts but doesn't run. Somebody has happened? you have any suggestions?

  • Transfer photo images from laptop

    Hi, I have just bought a 15-inch Powerbook and was wondering what is the easiest way to transfer photos taken on a shoot (and loaded/edited on the Powerbook) onto my G5 iMac. As a keen photographer, I will need to do this regularly. I want to be able

  • Hyp analyzer install error

    Hi, I am installing Hyp analyzer 7.2.5. Can any one tell me ..why the below warnings are arising The InstallShield Wizard has successfully installed Hyperion Analyzer 7.2.5. Choose Finish to exit the wizard. However, the following warnings were gener

  • Play Counts and Playlist Transfer

    I have a new PC and have saved my existing library to the exterbal hard drive. The new PC came with the latest itunes program and although I can transfer the music into the new itunes program, my playlists and play counts do not come with it. Any tho