Replacing text in a string

Hello. I am pulling in a friend's rss feed and we are trying
to figure out how to make images display correctly. Here is a
sample chunk that I pull in:
I am posting a forum image here Image:
http://mysite/test.jpg
How would I be able to make the "Image:
http://mysite/test.jpg" part if
that post change to "<img src="
http://mysite/test.jpg">"
I tried REReplace but couldn't get it to replace correctly.
Can someone please help me out?

well, i'm no regex guru... that pattern to match a URL was
found via google :)
the rest of it is pretty straightforward. find any instance
of "Image: " followed by the URL pattern. The URL pattern is
enclosed in parentheses which means we can reference it later as
\1. so you now have that URL in what's essentially a variable...
pop that variable into the <img src= /> and that's all she
wrote.

Similar Messages

  • Find and Replace text string in HTML

    Opps... I hope this forum is not just for Outlook. My Html files reside on my hard-drive. I am looking for VBA code to open specified file names ####File.html and then find and replace text strings within the html for example "####Name" replaced
    with "YYYYY"
    I drive the "####File.html" names and the find and replace text strings from an Excel sheet. I am an artist and this Sub would give me time to paint instead of find and replace text. Thank you!
    [email protected]

    Hello Phil,
    The current forum is for developers and Outlook related programming questions. That's why I'd suggest hiring anybody for developing the code for you. You may find freelancers, for example. Try googling for any freelance-related web sites and asking such
    questions there.
    If you decide to develop an Outlook macro on your own, the
    Getting Started with VBA in Outlook 2010 article is a good place to start from.

  • Applescript: open Pages doc from Templete, change filename and replace text

    Hi!
    I just got started with applescript and i want a script that does the following:
    1. open "choose from list" dialog to choose the topic of my document
    from 4 possibilities (here for example A, B, C, D)
    2. open document from TemplateXY
    3. set document name with date and topic (dd.mm.yyy) "16.02.2011 - A"
    4.inside of document: replace text "date" with the currend date (dd.mm.yyy)
    and the text "topic" with the topic chosen in (1.) "A"
    this is what i already did:
    here as colored screenshot:
    http://i55.tinypic.com/2mnhxkm.jpg
    set datum to do shell script "date \"+%d.%m.%Y\""
    --choose topic:
    set chosentopic to choose from list {"A", "B", "C", "D"}
    --text "topic" becomes replaced throug variable topic
    set searchstringT to "topic"
    set replacestringT to chosentopic
    --text "date" gets replaced by currend date (variable datum)
    set searchstringD to "date"
    set replacestringD to datum
    --open pages, define filename & do search&replace of the strings defined above
    tell application "Pages"
    activate
    set DocName to datum & " - " & chosentopic
    set (every text where it is searchstringT) to replacestringT
    set (every text where it is searchstringD) to replacestringD
    end tell
    the "choose from list" dialog works and the variables like topic, datum and the search&replace strings get defined as well
    my problems are:
    i only get an error that the text could not be replaced
    i dont know how to get a new document from a template and how to get its filename changed
    i really just started doin things with applescript for a day so i hope you can help me
    regards
    DaNylz
    Message was edited by: DaNylz

    Try something like this:
    set myFoundItems to change text text of all page items of pages 3 thru 5 of document 1
    Shane Stanley <[email protected]>
    AppleScript Pro Sessions <http://scriptingmatters.com/aspro>

  • Folder action to find and replace text and change line feeds

    I want to use a folder action to find and replace text and change Mac carriage returns to DOS line feeds inside text files.
    The text to be replaced is: "/Users/wim/Music/iTunes/iTunes Music/Music" (without the quotes)
    This text has to be removed (i.e. replaced by an empty string)
    The text occurs many times within each file.
    The files are playlists exported from iTunes in the M3U format (which are text files). They contain Mac carriage returns. These need to be changed to DOS line feeds.
    I have found the following two perl commands to achieve this:
    To find and replace text: perl -pi -w -e 's/THIS/THAT/g;' *.txt
    To change carriage returns to line feeds: perl -i -pe 's/\015/\015\012/g' mac-file
    I know that it's possible to make a folder action with Automator that executes a shell script.
    What I want to do is drop the exported playlists in M3U format in a folder so that the folder action will remove the right text and change the carriage returns.
    My questions are:
    Is it possible to make a folder action that executes command line commands instead of shell scripts?
    What is the correct syntax for the two commands when used in a folder action shell script? Especially, how do I escape the slashes (/) in the string to be removed?
    Thanks for your help

    Ok, I've include an applescript to run a shell command. The applesript command quoted form makes a string that will end up as a single string on the bash command line.  Depending on what you want to do, you may need multiple string on the bash command lines.  I've included some information on folder actions.
    It is easier to diagnose problems with debug information. I suggest adding log statements to your script to see what is going on.  Here is an example.
        Author: rccharles
        For testing, run in the Script Editor.
          1) Click on the Event Log tab to see the output from the log statement
          2) Click on Run
        For running shell commands see:
        http://developer.apple.com/mac/library/technotes/tn2002/tn2065.html
    on run
        -- Write a message into the event log.
        log "  --- Starting on " & ((current date) as string) & " --- "
        --  debug lines
        set desktopPath to (path to desktop) as string
        log "desktopPath = " & desktopPath
        set unixDesktopPath to POSIX path of desktopPath
        log "unixDesktopPath = " & unixDesktopPath
        set quotedUnixDesktopPath to quoted form of unixDesktopPath
        log "quoted form is " & quotedUnixDesktopPath
        try
            set fromUnix to do shell script "ls -l  " & quotedUnixDesktopPath
            display dialog "ls -l of " & quotedUnixDesktopPath & return & fromUnix
        on error errMsg
            log "ls -l error..." & errMsg
        end try
    end run
    How to set up a folder action.
    1) right click on folder. click on Enable folder actions
    2) Place script in
    /Library/Scripts/Folder Actions Scripts
    3) right click on folder. click on attach folder action
    pick your script.
    Create a new folder on the desktop & try.
    You can put multiple folder actions on a folder. There are other ways of doing this.
    Here is my test script:
    on adding folder items to this_folder after receiving dropped_items
        repeat with dropped_item_ref in dropped_items
           display dialog "dropped files is " & dropped_item_ref & " on folder " & this_folder
        end repeat
    end adding folder items to
    How to  make the text into an AppleScript program.
    Start the AppleScript Editor
    /Applications/AppleScript/Script Editor.app
    In Snow Leopard it's at: /Applications/Utilities/AppleScript Editor
    Copy the script text to the Applescript editor.
    Note: The ¬ is typed as option+return.  ption+return is the Applescript line continuation characters.
    You may need to retype these characters.
    Save the text to a file as an script and do not check any of the boxes below.

  • Find and replace text in multiple Photoshop files?

    Hi there,
    Let us say I have six Photoshop files: 1.psd, 2.psd, ..., 6.psd. All of these files contain the word “LoremIpsum” in random text layers, within each document. Is there a way I can search for “LoremIpsum” in all documents and replace it with “Dolor Sit Amet”, all in one go? This is just an example, I need to replace various words, not just one.
    I have tried "batch find and replace" software (including powerful tools like Power Grep) but they do not work with psd files… Is there a javascript of external plugin for this kind of task?
    Thanks!

    You’re welcome, advice given here is free.
    If you want to donate something nonetheless you could do so over at
    http://ps-scripts.com/bb/
    Many of the same people used to contribute there as here and I for one have benefitted considerably from their generous advice on Scripting issues.
    A Script can read (or create) txt files, but I do not have a lot of experience with this.
    This might work (amend the line »var theTexts = readPref ("….txt", false);« according to your txt-file’s path):
    // replace text elements in type layers;
    // 2013, use it at your own risk;
    #target photoshop
    if (app.documents.length > 0) {
              for (var n = 0; n < app.documents.length; n++) {
                        app.activeDocument = app.documents[n];
                        app.activeDocument.suspendHistory("replace text", "main()")
    // the opertation;
    function main () {
              var myDocument = app.activeDocument;
              var theTexts = readPref ("….txt", false);
              var theArray1 = theTexts.slice(0, Math.round(theTexts.length/2));
              var theArray2 = theTexts.slice(Math.round(theTexts.length/2), theTexts.length);
              alert (theArray1.join("\n")+"\n\n\n"+theArray2.join("\n"))
              for (var b = 0; b < theArray1.length; b++) {
                        replaceText (theArray1[b], theArray2[b])
    ////// reoplace text //////
    function replaceText (replaceThis, replaceWith) {
    // =======================================================
    var idreplace = stringIDToTypeID( "replace" );
        var desc22 = new ActionDescriptor();
        var idnull = charIDToTypeID( "null" );
            var ref3 = new ActionReference();
            var idPrpr = charIDToTypeID( "Prpr" );
            var idreplace = stringIDToTypeID( "replace" );
            ref3.putProperty( idPrpr, idreplace );
            var idTxLr = charIDToTypeID( "TxLr" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idAl = charIDToTypeID( "Al  " );
            ref3.putEnumerated( idTxLr, idOrdn, idAl );
        desc22.putReference( idnull, ref3 );
        var idUsng = charIDToTypeID( "Usng" );
            var desc23 = new ActionDescriptor();
            var idfind = stringIDToTypeID( "find" );
            desc23.putString( idfind, replaceThis );
            var idreplace = stringIDToTypeID( "replace" );
            desc23.putString( idreplace, replaceWith );
            var idcheckAll = stringIDToTypeID( "checkAll" );
            desc23.putBoolean( idcheckAll, true );
            var idFwd = charIDToTypeID( "Fwd " );
            desc23.putBoolean( idFwd, true );
            var idcaseSensitive = stringIDToTypeID( "caseSensitive" );
            desc23.putBoolean( idcaseSensitive, false );
            var idwholeWord = stringIDToTypeID( "wholeWord" );
            desc23.putBoolean( idwholeWord, false );
            var idignoreAccents = stringIDToTypeID( "ignoreAccents" );
            desc23.putBoolean( idignoreAccents, true );
        var idfindReplace = stringIDToTypeID( "findReplace" );
        desc22.putObject( idUsng, idfindReplace, desc23 );
    executeAction( idreplace, desc22, DialogModes.NO );
    ////// read prefs file //////
    function readPref (thePath, binary) {
      if (File(thePath).exists == true) {
        var file = File(thePath);
        file.open("r");
        if (binary == true) {file.encoding= 'BINARY'};
        var theText = file.read();
        file.close();
        return String(theText).split(",")
    In this case the comma is used to split the text into Strings in Arrays, if your search/replace texts include commas you could use something else, I guess.

  • Replacing text in a text file with special characters

    Hi all,
    in my test text file i found an interesting issue, where i can't replace text that looks something like this "New Text Document - Copy (2).txt"
    (gc $logeps)|foreach{$_ -replace "$($file.name)",""}|Out-File $logeps
    the context of my $($file.name) is "New Text Document - Copy (2).txt"
    how can i escape the parentheses characters inside of a variable that i am passing?
    thanks

    That should work if you're running PowerShell 3.0 or later, but in older versions, you'd run into errors if you try to run .Replace on an array of strings.
    While I prefer the string .Replace method in this instance, for future reference, if you want to escape a literal string so it can be used in a regular expression, call the [regex]::Escape method:
    $pattern = [regex]::Escape($file.Name)
    (gc $logeps) -replace $pattern | Out-File $logeps

  • Find & Replace Text - Styling Problem (CS5 Mac)

    Hi everyone,
         Is there a way when finding and replacing a text string to style the block of copy. My problem is that I have some color codes given by the customer that now need to be converted to our internal color matches on our production drawings.
    The original string of text looks like this:
    Holder: P1 (Metallic Silver)
    What I’m getting when I go to replace this string is:
    Holder: Natural Satin
    What I want is:
    Holder: Natural Satin
    I do not want the replaced text to be italicized. I'm thinking since the original string ends with an italic style that the replacement string is also italicized. There are about 50 pages of drawings with about 10 colors on the job and some pages have them entered in more than one place. So that's a minimum of 500 entries and defititely more considereing the multiple places these are called out. I'd really rather not have to copy and paste all of these by hand. I'm use to FreeHand, which would respect the font styling of pasted text in the find and replace diaglog.
    Any help would greatly be appreciated. Work around if it cant be done natively?
    Thanks

    Thanks Monika,
         I downloaded that earlier today and yes realized that the beta is over after installing it. I joined the mailing list for updates, but it looks like the script hasn't been updated in nearly 3 years. I'm not sure if something in one of the newer versions of Illustrator broke the script and the script writer decided not to update it anymore? I guess I could email them, but seems weird that if there were an updated version that it would be posted on the site also. I'd hate to pester the author. Seems like an extremely useful tool if it would do what I need. I suppose it couldn't hurt to ask anyway. I don't mind supporting developers too by paying for the script. This is something that I use all the time. I've spent about an hour and a half copying and pasting these text blocks for something that truly take about 2 minutes to do with a proper find and replace.
    I do appreciate your input though, it's greatly appreciated.

  • CS3: grep search to replace part of a string

    Can I do a grep search for a string of text but only replace a portion of the string while leaving the remainder intact?
    iMac G5, OS 10.5.5

    In addition to Eric:
    Find "some search string", Replace "some replacement string " also replaces part of the string, not touching anything...
    But the GREP search has two advantages: First, if you define formatting in the Replace field (italics, superscript, a character style), only the 'search'/'replacement' part will be affected, rather than the entire found string (as in regular search).
    The second big advantage is you can use any regular GREP single character wildcard in the 'left' and 'right' (matching-but-not-marking) parts. A few useful examples: '\d' (digit), '\l' and '\u' (lowercase and uppercase), '.' (any character), or even '[a-f]' (lowercase 'a' to 'f'). The only limitation is that you cannot use the once, zero-or-more, or once-or-more modifiers -- the strings must have a fixed length. FYI, those three modifiers are, respectively, ?, *, and +.
    This restriction does not apply to the 'middle' string, the one you are going to replace anyway -- use whatever GREP you want.

  • Use VBA and Excel to open Dreamweaver HTML (CS5), find and replace text, save and close

    I wish to use VBA and Excel to programmatically open numbered Dreamweaver HTML (CS5) and find and replace text in the code view of these files, save and close them.
    I have  5000 associations between Find: x0001 and Replace: y0001 in an Excel sheet.
    I have the VBA written but do not know how to open, close and save the code view of the ####.html files. Please ... and thank you...
    [email protected]

    This is actually the code view of file ####.html that I wish to find and replace programmatically where #### is a four digit number cataloguing each painting.... In 1995 I thought this was clever... maybe not so clever now :>)) Thank you for whatever you can do Rob!
    !####.jpg!
    h2. "Name####"
    Oils on acrylic foundation commercial canvas - . xx X xx (inches) Started
    Back of the Painting In Progress </p> </body> </html>
    Warmest regards,
    Phil the Forecaster, http://philtheforecaster.blogspot.ca/ and http://phils-market.blogspot.ca/

  • Find and replace value in Delimited String

    Hi All,
    I have a requirement, where i need to find and replace values in delimited string.
    For example, the string is "GL~1001~157747~FEB-13~CREDIT~A~N~USD~NULL~". The 4th column gives month and year. I need to replace it with previous month name. For example: "GL~1001~157747~JAN-13~CREDIT~A~N~USD~NULL~". I need to do same for last 12 months.
    I thought of first devide the values and store it in variable and then after replacing it with required value, join it back.
    I just wanted to know if there is any better way to do it?

    for example (Assumption: the abbreviated month is the first occurance of 3 consecutive alphabetic charachters)
    with testdata as (
    select 'GL~1001~157747~FEB-13~CREDIT~A~N~USD~NULL~' str from dual
    select
    str
    ,regexp_substr(str, '[[:alpha:]]{3}') part
    ,to_date('01'||regexp_substr(str, '[[:alpha:]]{3}')||'2013', 'DDMONYYYY') part_date
    ,replace (str
             ,regexp_substr(str, '[[:alpha:]]{3}')
             ,to_char(add_months(to_date('01'||regexp_substr(str, '[[:alpha:]]{3}')||'2013', 'DDMONYYYY'),-1),'MON')
    ) res
    from testdata
    STR
    PART
    PART_DATE
    RES
    GL~1001~157747~FEB-13~CREDIT~A~N~USD~NULL~
    FEB
    02/01/2013
    GL~1001~157747~JAN-13~CREDIT~A~N~USD~NULL~
    with year included
    with testdata as (
    select 'GL~1001~157747~JAN-13~CREDIT~A~N~USD~NULL~' str from dual
    select
    str
    ,regexp_substr(str, '[[:alpha:]]{3}-\d{2}') part
    ,to_date(regexp_substr(str, '[[:alpha:]]{3}-\d{2}'), 'MON-YY') part_date
    ,replace (str
             ,regexp_substr(str, '[[:alpha:]]{3}-\d{2}')
             ,to_char(add_months(to_date(regexp_substr(str, '[[:alpha:]]{3}-\d{2}'), 'MON-YY'),-1),'MON-YY')
    ) res
    from testdata
    STR
    PART
    PART_DATE
    RES
    GL~1001~157747~JAN-13~CREDIT~A~N~USD~NULL~
    JAN-13
    01/01/2013
    GL~1001~157747~DEC-12~CREDIT~A~N~USD~NULL~
    Message was edited by: chris227 year included

  • Trouble with "add note to replace text" annotation

    When I use "Add note to replace text" in Reader XI, the note acts as if it is locked even though it is not. The Locked box is not checked, but yet the options are grayed out; and I cannot delete the note, though I can edit the text box. "Strikethrough" and "Insert text at cursor" work fine.
    I am using the latest update of XI and have uninstalled and reinstalled it several times; I've also tried various older versions of XI. It happens with documents I've created or documents others have created; it happens on docs created from Word or those created from InDesign; it happens on docs downloaded several years ago as well as ones from the past month.
    I CAN delete these add-and-replace notes if I receive a file with them already put there by someone else--I just can't delete my own that I am adding right now. When I send the pdf to other people they have the same problem--in fact, someone told me that in her case ALL of my notes appear locked, not just the Add note to replace text one--yet when I send it to her, on my side, I have not locked any of them.
    Also, I do seem to be able to delete my own annotations I put on documents fairly recently--I have files from Sept 9 and Sept 17 that I can do this. But if I try to add notes to those same docs now, they act just like all the other ones--I cannot delete those particular notes and they appear locked.
    Help please!!

    You could write an html-text file that revers to the image file
    after that you could even convert this html-file to an rtfd file (which is a package after all) using textutil

  • How to display a text in a string as a link??

    Hi All,
    I am displaying a string in one of the column in my datagrid. I have to search for a specific text in the string and if it is there i have to display it as a link/linkbutton/button or anything which user can click.
    E.g
    String displayed in the datagrid column is "My Name is Pratik" and if text "Pratik" is found, i have to display "Pratik" as a link which user can click.
    How can i achieve this??
    Thanks

    If you want your text to be read-only, you can use the RichText component instead of TextArea. Search for Text Layout Framework for more info on how to mark up your text.

  • Replace text in photoshop document & save

    Hello,
    I have to make apprieciation certificates for a committee. Is there a way to use Automator to replace text within a photoshop document (people's names) and then save each name in a different file?
    Thanks!

    In theory, at least, this should be possible through an AppleScript which could be part of an Automator workflow, at least with Photoshop CS4 (I don't have earlier versions to check in their scriptability). The AppleScript suite for Photoshop CS4 has a text-object function that offers a lot of control over a given block of text, so it looks like it would be doable. You might want to take this up in the AppleScript forum or, probably better, in Adobe's own Photoshop forum.
    Regards.

  • How to convert a "text variable" to String with plugin

    Hello,
    I am currently developing a InDesign (CS5) plugin, where I need to manipulate text variable.
    From the plugin I want to convert the "text variable" to string (in principle I should use the method "VariableToString (..)" of "ITextVariable")"
    My problem is, how to find the text varial from its name (I think I should use the method "FindLocationsUsed(..)" of "ITextVariableSuite") and then convert it to String
    I don't know how to use interfaces ITextVariable and ITextVariableSuite
    Plugin implemented in C++ language
    thank you

         InputStreamReader in=new InputStreamReader(fis);
          StringWriter out=new StringWriter();
          char[] buffer=new char[8192];
          int sizeRead;
          while ( ( sizeRead=in.read(buffer, 0, 8192) ) != -1 )
            out.write(buffer, 0, sizeRead);
         String content=out.toString();

  • Search & replace text programmatically in pdf file

    I need to search & replace text programmatically (preferably in .NET c#) in existing pdf file.
    Does anyone know how to do it (maybe with with Acrobat SDK) ?
    Thanks in advance!
    A.
    PS: Well done working example :-)

    Searching APIs are provided, but there no APIs for replacing since that's not a standard operation on a PDF (given the rendering model).

Maybe you are looking for

  • Camera Profiles and PS Elements

    I'm a happy camper with LightRoom and the new profiles :-) A friend of mine have just bought a Nikon D60 and PSE. He is not ready start using a RAW convert yet but I'm sure he want to do that later. That's way I advice him to shoot RAW from the start

  • Global calculated key figures and their descriptions

    Hi, I currently have a strange problem concerning calculated key figures. We have several global calculated key figures which are used in approx. 100 querys. These key figures have a custom description ( not the same as the underlying keyfig info obj

  • Why are my new file contents not read?!

    Hi, I have a web application with a StartupServlet. In this Servlet my web application is initialised by reading out a file (init.xml) from disk. When the app server has been started and I modified the contents of the init.xml and reload the StartupS

  • Adding a new iCal event directly from an email

    Mail.app in MacOS X allows you to click on a date/time in any email in order to add the event directly to your calendar, in iCal. Is there a similar option in mail in iPhone 3.0? This would be so convenient - I cannot find anything like that but was

  • Usb support drivers ...

    I've been searching on how to enable my usb controllers on my k7t266 pro-r motherboard, but no luck. I'm using win98se. I now it's a bit outdated request, but if it weren't necesary I wouldn't call...