RegExp search and replace, keep the formatting of the original text

Hello!

Will have to perform the Search and replace within a framework of text using RegExp.

And to retain the original formatting of the text block.

How is it possible?

Bad example-, it converts all the text formatting to the format of the first character:

var reg = /a/gmi;
var replacer = '*';
var fr = activeDocument.textFrames[0];
fr.contents = fr.contents.replace (reg , replacer);

find_and_replace_regexp.jpg

Thank you!

I has not yet been tested your code.

But why you did not play with my code snippet, use something like this:

// regex_changeContentsOfWordOrString_RemainFormatting.jsx
// regards pixxxel schubser
var s = /arguments/gi;
var replacer = "other string", result;
var atf = activeDocument.textFrames[0];

while (result = s.exec(atf.contents)) {
    try {
        aCon = atf.characters[result.index];
        aCon.length = result[0].length;
        aCon.contents = replacer;
        } catch (e) {};
    }

Try it and have fun

Tags: Illustrator

Similar Questions

  • delete "Desktop Search" and replace with the original Windows search utility

    Under XP, (files and folders) Windows search has been replaced by "Desktop Search", which doesn't help.  How can I get the search utility original back?

    You can't do that.  There may be 3rd party applications that will do something similar.

    The search in XP has also been replaced in win 7 and win 8.

  • Search and replace for the color gradients?

    Just discovered new "Find and replace" tool which is very neat. However, I can't make it work with gradients. "Finding" a specific gradient if you replace all the forms with that color with another color United or degraded degraded? (Using Flash CS6; although entry users of old versions of Flash welcome whether applicable...)

    Hi Evilbob0,

    Search and replace for color, supports only solid colors.

    Gradients are not supported (in - Flash Pro CS6 and CC).

    Thank you

    Smriti

  • GREP: Search and replace

    Does anyone know if its possible to take a list (shown on the lower part of the image) and run a GREP search and replace to create the list of tabs (shown on the picture)?

    I know that the majority of it can be made with the regular search and replace: separate the first and last name; MD and MD #; Postal code and telephone number.

    What I was not able to understand is how to add a tab forward and backward the state abbreviations 2-digit, the Middle Initial, phone number and more important even if there is a way to add tabs in when there aren't the same amount of lines, such as the field of specialty.

    I know that I can use the GREP search and replace to add a tab before each paragraph back, then remove the tab where there are 2 paragraph after each game returns, then substituting a tab and a paragraph back to just a tab, together running all the rows in each set.

    Any help would be greatly appreciated, and if there is anywhere I can learn more about GREP, I would love to learn it.

    Thank you

    Peter

    Doctors List Styles.png

    Peter, try this...

    Find:------.<>

    Replace: \t$0

  • Reformatting of files in Dreamweaver: series of files (search and replace) .dwr batch consecutively

    I have to do a reformat complicated of an entire site. It is simplified to a series of search and replace tasks for each file. Each search and replace string was recorded in a .dwr file. Currently, I load and run each .dwr file.

    How batch or automate this task in Dreamweaver? In other words, a series of files .dwr to consecutively run the tail?

    OK, here we go.

    This example, a simple command of Dreamweaver Extension, run two find and replace commands in a go. (It can be any number of commands find and replace).

    The first command replaces 'the' and 'this' "phe" and "phis". The second paragraph command replaces

      ...
      ...
    . (These can of course be all find and replace.)

    You need two files: an HTML file (for the UI) and a Javascript file (for actions). I named the 'Find and replace Test.html' and 'find and replace Test.js. (They can be any name).

    Find and replace the file Test.html

    
    
    
    Find and Replace Test
    
    
    
     

    Are you sure?

    Find and replace Test.js

    function canAcceptCommand() {
        return true;
    }
    
    function commandButtons() {
        return new Array("Go!", "doIt()", "Cancel", "window.close()");
    }
    
    function doIt() {
        dreamweaver.setUpFindReplace({
            searchString: "th(e|is)",
            replaceString: "ph$1",
            searchWhat: "document",
            searchSource: true,
            useRegularExpressions: true
        });
        dreamweaver.replaceAll();
    
        dreamweaver.setUpFindReplace({
            searchString: "<(/?)ul>",
            replaceString: "<$1ol>",
            searchWhat: "document",
            searchSource: true,
            useRegularExpressions: true
        });
        dreamweaver.replaceAll();
    
        window.close();
    }
    

    Basically, you can call any number of this pair of functions in the script:

    dreamweaver.setUpFindReplace(findAndReplaceObject);
    dreamweaver.replaceAll();
    

    Place these JS and HTML files in this directory:

    Application Dreamweaver/Configuration/Commands Directory.

    Then in Dreamweaver, open the window "insert." (You need to open an HTML file in order to make the active insertion window.) Above the insertion window, there is a drop down category ("Common" etc.). Do alt + click (ctrl + click) - then you'll see a 'Reload Extenesions' element at the bottom of the drop-down list. This will load this extension of DW. (Alternatively, you can restart DW to load the extension.)

    It is now ready to run the Extension. Open an HTML document that you want to change. Go to the 'orders' in the menu bar. At the bottom of the drop-down list, there is an article "find and replace Test." Select and enjoy

    Notes

    General ordering example Extension in the doc: http://help.adobe.com/en_US/dreamweaver/cs/extend/WS5b3ccc516d4fbf351e63e3d117f53d6ec3-7fe 6 html

    I hope that all these wise...

    --

    Kenneth Kawamoto

    http://www.materiaprima.co.UK/

  • Search and replace the string formatting

    Hello

    I try to do a search and replace the formatting of a string.

    In the example, I'm looking for the string 'SUCCESSFUL', but it must also begin by usbflash and some number + PASSED.

    I can't get the format to have a number between 1 and 99. The number of replacements should add up to 6 in this case. I tried with \d for any number, and I also tried [1-99].

    Make a right-click on the function search and replace the string.  There is an option to use regular Expressions.  Then give it a try.

    EDIT: You need to set the entry replace all to TRUE.

  • Advanced search and replace. How to replace the space with carriage return?

    10.9.13.0/24, 10.9.4.2/32, 10.9.4.3/32

    in

    10.9.13.0/24
    10.9.4.2/32
    10.9.4.3/32

    Find replace them ',' with carriage return.

    I still find articles on an advanced search and replace, but I can't seem to locate it.

    OS X El Capitan 10.11.3

    3.6.1 the numbers

    HI Brendan,

    You don't need an advanced find and replace for it.

    In the search box, press, then space.

    In the box replace by, press option-return.

    Then click Find and replace and find until you are finished.

    Kind regards

    Barry

  • I can't seem to make the "search and replace string" works as expected.

    I tried to replace "^ []] +---+ ([^] +).» "$*" with $1 in "create table leq_octave_5min (recorded_time DATETIME CONSTRAINT pk1 PRIMARY KEY, leq5m leq5m of FLOAT CONSTRAINT NOT NULL, min min FLOAT CONSTRAINT NOT NULL, max max FLOAT CONSTRAINT NOT NULL, CONSTRAINT of FLOAT L05 05 NOT NULL, CONSTRAINT of FLOAT L10 10 NOT NULL, L50 FLOAT CONSTRAINT 50 NOT NULL, L90 FLOAT 90 CONSTRAINT NOT NULL. L95 FLOTTER CONSTRAINT 95 NON NULL, us01 us01 FLOAT CONSTRAINT NOT NULL, EN02 EN02 FLOTTER CONSTRAINT NOT NULL, fr03 FR03 FLOTTER CONSTRAINT NOT NULL, fr04 FR04 FLOTTER CONSTRAINT NOT NULL, fr05 FR05 FLOTTER CONSTRAINT NOT NULL, fr06 FR06 FLOTTER CONSTRAINT NOT NULL, fr07 FR07 FLOTTER CONSTRAINT NOT NULL, fr08 FR08 FLOTTER CONSTRAINT NOT NULL, fr09 FR09 FLOTTER CONSTRAINT NOT NULL, fr10 FR10 FLOTTER CONSTRAINT NOT NULL Fr11 FR11 FLOTTER CONSTRAINT NOT NULL, FR12 FLOTTER CONSTRAINT NOT NULL fr12, fr13 FR13 FLOTTER CONSTRAINT NOT NULL, fr14 FR14 FLOTTER CONSTRAINT NOT NULL, fr15 FR15 FLOTTER CONSTRAINT NOT NULL, fr16 FR16 FLOTTER CONSTRAINT NOT NULL, fr17 FR17 FLOTTER CONSTRAINT NOT NULL, fr18 FR18 FLOTTER CONSTRAINT NOT NULL, fr19 FR19 FLOTTER CONSTRAINT NOT NULL, fr20 FR20 FLOTTER CONSTRAINT NOT NULL, fr21 FR21 FLOTTER CONSTRAINT NOT NULL Fr22 FR22 FLOTTER CONSTRAINT NOT NULL "(, e23, e23 FLOTTER CONSTRAINT NOT NULL, fr24 FR24 FLOAT CONSTRAINT NOT NULL, fr25 FR25 FLOTTER CONSTRAINT NOT NULL, fr26 FR26 FLOTTENT CONSTRAINT NOT NULL, fr27 FR27 FLOTTER CONSTRAINT NOT NULL, fr28 FR28 FLOTTER CONSTRAINT NOT NULL, fr29 FR29 FLOTTER CONSTRAINT NOT NULL, fr30 FR30 FLOTTER CONSTRAINT NOT NULL, status TEXT (2) st NOT NULL CONSTRAINT).

    The goal was to get the third token, 'leq_octave_5min '.

    The result string is "leq_octave_5min", but the real result string is the input string itself.

    What is the problem with my method?

    I'm sorry.

    I forgot to turn on 'regular expressions' in "Search and replace the String" VI.

    After having turned it on, it works as expected.

  • How can I use search and replace to replace the title of the doc with copy of the h1 content?

    I have a site with about 300 pages which have the same title. I need to replace this title by the same text that appears in the h1 tag on the page (each page is different). Of DW search and replace it? If so, how? I don't really want to go have to go to each page and copy/paste.

    jeffsure wrote:

    Is there a way to tell him to put only the first h1 tag in the title?

    I'm really motivated now to learn regex!

    Yes. Just use the following regular expression instead of the previous:

    ([^<>[\S\s]+?

    )([^<>

    The field is to replace the same.

    The question mark is the [\S\s]+ a lazy search, stopping at the first]

    rather than doing a greedy research that concludes the last

    in the page.

    The regex for learning is difficult, but it can be very rewarding. I would only like the best.

  • [CS5 JS] excluding the Notes of search and replace

    Hello

    Does anyone know how to exclude all text within a Note of a search/replace, text or grep operation?

    I went through and systematically all the findChangeGrepOptions that had the word "include" in false:

    includeLockedStoriesForFind: false

    includeLockedLayersForFind: false

    includeHiddenLayers: false

    includeMasterPages: false

    includeFootnotes: false

    just to check, but nothing has worked. myText.changeGrep () has again changed the text in the note.

    Of course, it would be pretty easy to write a wrapper function

    var myChangeGrep = function( textObject, checkNotes ) {
       checkNotes = checkNotes || false;
       results = [];
    
      // Go through and run changeGrep on all the 
      // parts of the textObject that are not contained inside Notes, 
      // (or just run it on the entire textObject if checkNotes is true),
      // and push the results to the results array as we go along.
    
      return results;
    };
    

    but it has the disadvantage that it returns a table and not a collection of InDesign, as does the regular changeGrep. In addition, as simple as it may be, it would be easier if there was a preference somewhere to take care of this.

    Any idea?

    Thank you!

    There is no preference for that: the scope of search and replace can be set only with five preferences that you have already tried. (In the same way, you can not include/exclude tables.) findGrep() and changeGrep() return an array, for that matter, not a collection.

  • Try to find the queries of search and replace

    OK, I thought I knew where it was.  I looked at

    C:\Users\phyllis\AppData\Local\Adobe\InDesign\Version 6.0\en_US\Caches
    He has here called FindChangeData and FindChangeDataTmp files, but write them in the folder for the Version 7.5 does nothing.

    So I think I'm looking in the wrong place.  I'm moving all the queries search and replace in InDesign CS 5.5.  Can someone point me to them?

    Thank you, Phyllis

    Try C:\Users\\AppData\Roaming\Adobe\InDesign\------------.

  • Restrict the search and replacement of real pages

    I try to limit a "find and replace" to the real page, I work in my javascript.

    Is it possible and how can it be done?

    Thank you!

    Well, if you have a look at the DOM of InDesign (under the Help menu

    ESTK), you will see that a page has a property called executives from related, which is

    a collection of blocks of text on this page.

    So, to find all the blocks of text on a given page, you should be able to:

    myFinds = myPage.textFrames.everyItem () .findText ();

    Ariel

  • global search and replace prices

    I have about 20 catalogs I want to keep available online, but I want to delete prices.  Can anyone think of a way to do it with the global search and replace?  I think that I would have to do each doc separately because I don't want to remove all catalogs online prices.

    Thank you!

    I'm no expert with Regular Expressions, but I think it will work, assuming that all of your prices are in this format: $39.95 or $45.00.

    Search the Source Code.

    Check 'use the regular Expression' in the search panel & replacement

    Find: \W\d\d.\d\d

    Replace:

    NOTE: Test on a single page before trying it on your whole site or a folder. In addition, make backups before you start, just in case it does not work to plan.

    Nancy O.
    ALT-Web Design & Publishing
    Web | Graphics | Print | Media specialists
    http://ALT-Web.com/
    http://Twitter.com/ALTWEB

  • Search and replace Question

    I would like to find text in a document and add a space at the beginning of a style. I can't simply replace text because its different text throughout the book. Is there a way to invke the Clipboard in one search and replace? For example...

    If ^ c were the command to copy and paste the selection yould be able to use

    ' ^ m ^ p ' in the section replace, add a space in the world, it finds my search criteria.

    One more thing, im stuck semi with CS3 to do this and would like to keep in CS3, but might, if I'm using CS4 and then export to CS3... new id really prefer does not however.

    I think you're going to need two styles, one for the first paragraph of the quotation and the other for the following paragraphs in the citation. What you do universally for the style, if you have only one, will affect all paragraphs with this style.

    You never responded to my previous questions as these quotes don't in running text or separate executives. If they are in the text running there is no reason to use the paragraph NET, unless you want to push the line down, at the top of a column (which, in my opinion is ugly and one of the main arguments against the addition of an empty paragraph). The space is a better and simpler choices. If the quotes are in separate frames, you can adjust the Insert at the top of the page text to push. You don't need anything special at all (nor a second style), and you can save as part of a style object.

    Overall, my response to this question is that you approach the problem from the wrong direction. It's just a matter of definition of style, if style paragraph or style object and find/replace should play no role, except perhaps to allow you to easily locate the quotes to change the style of the first paragraph. You'll still need to do them one by one, but find the change can locate all so you do not need to go page by page.

  • Search and replace advanced help

    First of all thank you for reading.  I come here as a last resort to see if there is a solution to a problem I have.

    Basically, I need to rename thousands of images in a blog of backup that is transferred to a new host.  The format of the images are as follows

    < img alt = "Revlon pedi-egg" border = "0" src = "images/6a00d8341c873353ef011572419566970b - 800wi.jpg" / >

    where each image several thousand has a unique alt tag and a unique image name

    I want dreamweaver to find the alt tag can replace the name of the image, so that the picture above would become

    < img alt = "Revlon pedi-egg" border = "0" src = "images/Revlon-pedi-egg...". "jpg" / > "

    I used expressions to replace before as well (. *) etc. but I can't get it to work.

    Is it possible and if so someone would be nice of you to give me some advice?

    FIRST MAKE A BACKUP.

    Test first in several pages.

    In Dreamweaver find and replace, select the following options:

    Find: current Document

    Search: Source Code

    To find:

    ([^Replace:

    $1$2src=
    

    Select use regular expression.

    Once you are confident that the changes are correct, you can then do it for an entire folder or all of the current site.

    This means that all your image tags to use quotes around the values of attribute as shown in your original post.

Maybe you are looking for

  • Several desktop computers

    Hello I use several computers desktop (accessible by the Mission control). I just added a third and my apps are bad! I have a set for Outlook upward and a few other applications, office (Word, etc) applications and my third new office for Adobe CC ap

  • temporary loss of bluetooth technology

    Bluetooth on my Macbook Air deletes periodically.  It's particularly irritating when my mouse from Apple, or mirroring my Macbook Air with my Apple TV (Gen-4). Does anyone have any solution to this problem?

  • My email continuous to send unwanted emails to everyone on my list of contacts HELP!

    Every morning my email sends, _ just my name to my business contacts and of his words "buy viagra" or something... I don't know how to get rid of it my email is through hotmail.

  • stop stalker/halker fall into my netbook

    My x is constantly breaking into my computer.  He has experience in computer science and professional at his disposal.  I think that it is outside the House and look through our open wifi.  I can't close the wifi and I meet the close all in the comin

  • (Redirected) 32-bit to 64-bit problem!

    Hi all I have a Dell D630 and recently installed Windows 7 64 bit on it. He had Windows 7 32 bit installed before and the laptop is 64-bit compatible I thought that an upgrade would be much better, but since I have updated it seems slower and much le