Regex replacement syntax in editor

Hello all,
for the life of me I can't remember (nor find in the documentation) the syntax for doing string replacements using regular expressions in the CVI editor.
Something like:
Search: ({[~,]*},
Replace: (\1, A10,
Would change the string "(aei1," to "(aei1, A10,"
But what are the delimiters to use ? {} like in my example ? And what's the variable ? \1 ? $1 ?
I just can't find it.
In sed syntax:
sed -e "s/(\([^,]*\),/(\1, A10,/"

No, it's not in there. Here's the relevant doc from sed for what I want:
       s/regexp/replacement/
              Attempt to match regexp against the pattern space.  If successful, replace that portion  matched  with  replacement.   The replacement  may contain the special character & to refer to that portion of the pattern space which matched, and the special escapes \1 through \9 to refer to the corresponding matching sub-expressions in the regexp.
I'm sure I've used it with the CVI editor before.

Similar Messages

  • Variable in regex replace pattern

    Hi,
    I need to use a variable in a regex replace pattern - how can I do it? Specifically, I need to pass arguments to a shell script that then uses that argument in a replace pattern:
    #!/bin/bash
    #$1 now holds the argument
    sed 's/searchpattern/replace_pattern_with_variable$1/g' file1 > file2
    when I run this, the replace pattern uses $1 as a literal string "$1" and not the variable value. How can I change this?
    Thanks!
    Ingo

    Hi Ingo,
       As Vid points out, the issue is that single quotes protect strings from shell interpretation. You need to have the dollar sign, '$', visible to the shell or it won't read what follows as a variable name. Using double quotes works because the shell "reads through" those.
       However, complex regular expressions can contain lots of characters that the shell interprets. These can be quoted individually by backslashes but the use of backslashes in regular expressions is complex enough without the addition of shell interpretation. I find it easiest to keep the single quotes and only expose the part of the string that the shell needs to interpret.
       The shell doesn't have a special string concatenation character. All you have to do is to put the strings beside each other with nothing in between and the shell will concatenate them. Therefore it's possible to write your example as:
    sed 's/searchpattern/replace_pattern_with_variable'${1}'/g' file1 > file2
    That is, one closes the single quote right before the variable and then resumes it immediately afterward. The shell will put these quoted strings together with the contents of the variable just as it would with double quotes but you still enjoy the protection of single quotes around the rest of the string!
    Gary
    ~~~~
       P.S. Perl's master plan (or what passes for one) is to take
       over the world like English did. Er, as English did...
          -- Larry Wall in <[email protected]>

  • Efficient regex replace function? Help!

    Here's what I'm trying to do:
    Scan through a string, and replace any occurences of http://...... (until the next space) with an HTML link. Does anyone know what would be the most efficient regex replace function to do this?
    Thank you very much in advance.

    class StringReplaceDemo{
         public static void main (String args[]){
              String mystr = "This is hyperlink to Google http:// . From there you can search for any thing in the world";
              String google = "http://www.google.com";
              String hyperlink = "http://";
              int hyperlinklength = hyperlink.length();
              int index = mystr.indexOf("http://");
              mystr = mystr.substring(0,index)+google+mystr.substring((index+hyperlink.length()),mystr.length());
              System.out.println(mystr);
    }

  • Applescript Regex Replace Usage

    I am using Applescript to do regex replace for a pattern of type APP[0-9][0-9][a-z][a-z] and display it as a hyperlink.
    Eg: APP23cc to APP23cc
           APP36ij to APP36ij
    I am getting the body of the email as a string.
    How could I do this?

    I'm not exactly clear on what you're trying to do (display the hyperlink where and how? what link are you trying to link?), but I can say that applescript does not do regexp natively.  you have two choices:
    download the Satimage osax so that you can do regexp
    use a simpler search pardigm
    a simpler search would require a repeat loop, like so:
    repeat with w in words of body
              considering case
                        if w begins with "APP" then
      -- do whatever you're trying to do here
                        end if
              end considering
    end repeat
    you can make that IF as detailed as you need it to be to specify the things you want to work with.

  • Understanding Regex replace method call involving delegate

    Hello,
    I am trying to understand the $regex.replace static method call below (I came across this code snippet in the cookbook).
    $replacer = {
    param($match)
    $chars = $match.Groups[0].Value.ToCharArray()
    [Array]::Reverse($chars)
    $chars -join ''
    $regex = [Regex] "\w+"
    $regex.Replace("Hello World wide", $replacer)
    What I do not understand is the below overloaded definitions for replace method do not seem to match the above replace call. So how exactly is this working? The above call has 2 parameters passed where as none of the below overloads have less than
    3 parameters.
    PS C:\WINDOWS> [regex]::replace
    OverloadDefinitions
    static string Replace(string input, string pattern, string replacement)
    static string Replace(string input, string pattern, string replacement, System.Text.RegularExpressions.RegexOptions options)
    static string Replace(string input, string pattern, string replacement, System.Text.RegularExpressions.RegexOptions options, timespan matchTimeout)
    static string Replace(string input, string pattern, System.Text.RegularExpressions.MatchEvaluator evaluator)
    static string Replace(string input, string pattern, System.Text.RegularExpressions.MatchEvaluator evaluator, System.Text.RegularExpressions.RegexOptions options)
    static string Replace(string input, string pattern, System.Text.RegularExpressions.MatchEvaluator evaluator, System.Text.RegularExpressions.RegexOptions options, timespan
    matchTimeout)

    What you are looking at are the static methods ([regex]::) and their appropriate parameters which in this case have a minimum of 3 parameters to properly perform the Replace using the input, pattern and replacement
    value. If you were to use the constructor of [regex] to create a pattern like this:
    $Regex = [regex]'\w'
    You will see that the Replace method here allows for only 2 parameters because you have already satisfied the pattern when you created the Regex object.
    $Regex.Replace
    OverloadDefinitions
    string Replace(string input, string replacement)
    string Replace(string input, string replacement, int count)
    string Replace(string input, string replacement, int count, int startat)
    string Replace(string input, System.Text.RegularExpressions.MatchEvaluator evaluator)
    string Replace(string input, System.Text.RegularExpressions.MatchEvaluator evaluator, int count)
    string Replace(string input, System.Text.RegularExpressions.MatchEvaluator evaluator, int count, int startat)
    Boe Prox
    Blog |
    Twitter
    PoshWSUS |
    PoshPAIG | PoshChat |
    PoshEventUI
    PowerShell Deep Dives Book

  • Using a local variable in regex portion of replaceAll(regex, replacement)

    While this works..
    output = output.replaceAll("(HED>|AUT>)(.*)(</\\1)", "$1<![CDATA[$2]]>$3");
    I'd like the list of alternation values to be contained in a variable, for example:
    String nodeLIst = "HED>|AUT>";
    output = output.replaceAll("(nodeList)(.*)(</\\1)", "$1<![CDATA[$2]]>$3");
    The extension of this would be so I can store this stuff in a db as a list and avoid compilation on change, but please don't let this muddy the waters... :)
    Any pointers are much appreciated. Links to specific reading material, etc. I've scoured Friedl's Mastering Regular Expressions to no avail. This approach is supported by some other regex engines I've used (perl, php, ORO?) but I'm new to Java.
    TIA,
    Mark

    I've scoured Friedl's Mastering Regular Expressions to no avail.Did you look on page 209? In the book, that code sample is labelled "Building Up a Regex Through Variables in Java". That should have been a clue. ^_^
    But seriously, you're probably thinking of the interpolated strings you find in scripting languages like Perl, PHP, Ruby, etc.. But that's a feature of the language itself, not the regex engine, and Java doesn't work that way. (The $1, $2, etc., in the replacement string are processed by the Matcher class, in a very limited imitation of Perl's variable interpolation).
    However, you can fake it pretty well with String's format() method:   String regex = String.format("(%s)(.*)(</\\1)", theAlternation);
      output = output.replaceAll(regex, "$1<![CDATA[$2]]>$3"); That way, you can easily escape the dynamic part, in case it might contain regex metacharacters:   String regex = String.format("(%s)(.*)(</\\1)", Pattern.quote(theAlternation));

  • RegEx replacement

    I'm trying to make a small parsing engine that does the following:
    1. reads an HTML document
    2. searches for special tags of the form [key]
    3. looks up the key in a hashmap or something
    4. replaces [key] with value from the hashmap
    I'm storing the HTML document line by line as strings in an ArrayList (any better way to do this?). I iterate through each line, replacing each tag with its corresponding value. The thing is, however, that I'd like to use RegEx as much as possible.
    The java.lang.String.matches(String regex) method tells me, through a boolean return value, whether the current line actually contains any tag at all , while the java.lang.String.replaceFirst(String regex, String replacement) method solves the replacement part. What the String class methods don't provide me with is a method for returning the actual substring that was found during the java.lang.String.matches(String regex) call. Is there any such method out there? Right now I'm doing this manually, using the String class' indexOf(...) and lastIndexOf(..) methods.
    In short, what I'm looking for is a method something like String find(String text, String regex) that would return "salary" when called as find("<h1>[salary]</h1>", ".*\\[.*\\].*")
    Thanks for your help!

    You must use Patterns and Matchers (java.util.regex.*).
    In short, what I'm looking for is a method something like String find(String text, String >regex) that would return "salary" when called as find("<h1>[salary]</h1>", ".*\\[.*\\].*")Let's
    String html
    be your input.
    Pattern p = Pattern.compile("(?im)<h1>(.*?)</h1>");
    Matcher m = p.matcher(html);
    if( m.find() ){
    // the whole matching substring is in m.group();
    // the string within the h1's is in m.group(1)
    }

  • Regex replace ^

    Hi trying to find a way of removing some text from a string where there is a ^ followed by either a number of character.  So I want to remove ^6 or ^h or whatever.  Trying the following:  var colorPattern:RegExp = /^[A-Za-z0-9]/g; match.replace(colorPattern,"");  I have tested the regex in a tester which seemed to work but this just returns match with the original text.  This is my first time using regex so any help would be appreciated.  Cheers Peter

    OK, figured it out. Here it is if anyone else needs to know
    <h1>(.+)</h1>
    <div id="background">
    replace with
    <div id="background">
    <h1>$1</h1>

  • Replace standard HTML editor..Please guide

    Hello All,
    Is it possible to replace HTML editor with another editor like JCE editor?
    If yes, please share your experience
    If not with JCE, please let me know as to which other editors can the HTML editor be replaced with?
    If the HTML editor cannot be replaced, is there a way to provide another option for KM users...something like the 'Open With...'option we have while working on windows.
    Awaiting Reply.
    Regards,
    Ritu

    Hello Sascha,
    Thanks for your reply.
    The initial requirement of client is to replace HTML editor with JCE editor.
    Will you able to tell me about the development effort for such integration.
    Secondly, am not sure this happens but just to be sure:
    Ive heard that some client users have edited the file offline but the moment they upload the doc/file in Portal/KM, some of the tags miss out.
    Including this, there are many other bugs in HTML editor and this is the reason why client wants to replace it.
    Thirdly, I had also suggested to go with Web Page Composer but then again, its buggy.
    We are on EP7 SP9
    Any thoughts on this?
    Awaiting Reply.
    Regards,
    Ritu

  • LabVIEW2009: How to replace new Icon Editor with old one?

    Colleagues,
    I really don't like the new icon editor introduced in LabVIEW 2009:
    That was nice attempt to make "embedded Photoshop" with lot of features:
    But I really don't like it, because:
    - it opened EVERY TIME on the RIGHT monitor (I have three monitors, and primary monitor in the middle) 
    - it takes lot of time for launch (old icon editor was started momentally)
    - from usability point of view - it was wrong to place tools on the right side. Commonly they located on the left side (and only in old icon editor, but also in imageprocessing software like Adobe Photoshop). Also front panel UI design... hmmm... this can be better...
    - some bugs or changed functionality (for example - select ROI, then press <Del> button - nothing happened)
    etc...
    Is it possible to replace it with old one:
    Ideal solution will be - simple switch between both editors (some introduced features are not so bad).
    Thanks in advance, 
    Andrey.
    Message Edited by Andrey Dmitriev on 01-29-2010 11:00 AM
    Solved!
    Go to Solution.

    Go into <LabVIEW>\Resource\Plugins and rename lv_icon.vi. This is the plugin that's called when you invoke the icon editor, and if it's not there, LV reverts to the built-in editor (at least today. I'm not sure how many versions ahead they will keep the code).
    You should note that the editor is open source, so you can go in and change what you want (or save yourself time and use the changes others have made, such as PJM's thread here. You may also want to look at the other discussions in that group).
    Try to take over the world!

  • Regex replacing multiple characters in string.

    I have been working through the Java regex tutorial and tried to modify one of the programs for my own use. Basically, I want to take a string and convert the chatracters A to T, T to A, C to G and G-C.
    I produced the rather crude program below, but of course it doesn't work. A could be converted to T and back again before the program terminates.
    I know that the code to do this correctly is probably quite complex, so could anyone point me in the direction of a tutorial which will help me to do this?
    This aside, I take it that if I am looking for multiple matches of characters which won't give the problem already indicated above, my code is too bloated anyway. Say, for example, instead of wanting to replace A to T, T to A, C to G and G-C, I wanted to replace dog-cat, horse-donkey - lion, tiger , cat-mouse. My code will work for this, but I am sure that it could be compressed a lot. Surely I would not need all the lines of code to do this?
    Thanks for any help,
    Tim
    import java.util.regex.Pattern;
    import java.util.regex.Matcher;
    import java.io.*;  // needed for BufferedReader, InputStreamReader, etc.
        /** A Java program that demonstrates console based input and output. */
         class dna {
            // Create a single shared BufferedReader for keyboard input
            private static BufferedReader stdin =
                new BufferedReader( new InputStreamReader( System.in ) );
            // Program execution starts here
            public static void main ( String [] args ) throws IOException
                // Prompt the user
                System.out.print( "Type your DNA sequence: " );
                // Read a line of text from the user.
                String DNA = stdin.readLine();
                DNA = DNA.toUpperCase();
                String DNA2 = DNA;
                //calculate reverse complement
                Pattern A = Pattern.compile("A");
                Pattern T = Pattern.compile("T");
                Pattern C = Pattern.compile("C");
                Pattern G = Pattern.compile("G");
                Matcher AA = A.matcher(DNA);
                DNA = AA.replaceAll("T");
                Matcher TT = T.matcher(DNA);
                DNA = TT.replaceAll("A");
                Matcher CC = C.matcher(DNA);
                DNA = CC.replaceAll("G");
                Matcher GG = G.matcher(DNA);
                DNA = GG.replaceAll("C");
                // Display the input back to the user.
                System.out.println( "DNA input             : " + DNA2);
                System.out.println ("Complementary sequence: " + DNA);
        }

    TimM wrote:
    Thanks a lot!!! Can't believe you managed all that with so few lines of code.You're welcome.
    Must be great to know what you are doing :-)
    Thanks again,
    TimAfter being a bit more familiarised with the methods of String, you'll be able to do this in no time, I'm sure!

  • Change or replace KM HTML Editor

    Hi again,
    I would like to customize the KM HTML Editor or replace it with another Editor.
    Has anyone done that before?
    If so, I'd like to know how to achieve that!
    I know this might be very complicated, but I appreciate every little hint!
    Best regards, Marko

    I figured it out myself, under System Administration - System Configuration - Knowledge Management - Content Management
    Utilities - Editing - HTML Editing
    There are these options:
    Always Use Secure HTML Editor
    Allow Only Basic Formatting
    Allow Links
    Activate Clipboard Buttons
    Allow Preview
    Allow Indenting
    Allow Tables
    Allow Bullets and Numbering
    Allow Images
    Allow Text Size and Font Settings
    Allow Color Settings
    On Dev we had all options ticked so for us that meant 'Allow Only Basic Formatting' was giving limited icons on the HTML Editor toolbar. It is worth noting that if 'Always Use Secure HTML Editor' is not ticked then the other options dont do anything, it is all based around this first option.

  • Syntax Higlighted Editor

    Hi,
    I saw in JavaFx Ensemble Demo, on the Source pane by each of the samples a highlited editor. Is this a real Component with Syntax highlight or just a HTML editor with Html behind ?
    I am looking for a Syntax enabled Component, where I can specify a language ( like Sql, Java, etc ) and the highlight is automatically done.
    Is this possible in JavaFx ?
    Thank you,
    Dragos

    Well. 1 out of two (Free): Emacs.
    Also still free I think, but not small, IBM's XML editor. I forget the name. It's on developerworks somewhere.
    Mike
    null

  • Php syntax highlighter/editor?

    Hi,
    Is there a way to add "*.php" as a file type so the editor will color the syntax?  Or maybe even add a new php editor all together...
    Thanks,
    Jeff

    diederick76 wrote:
    I agree there must be something going on that has little to do with the file mentioned. Even when I remove all the &s from line 107, or insert a few blank lines before line 107 (moving the supposedly wrong lines down) it still complains about &s in lines 107 and 108.
    But where do I look?
    I'd recommend checking your web server's config on wether a chroot is set or someting.
    You could also try
    sudo find / -name php.ini
    This should list all php.ini's in your file system, including the one php is actually using.

  • Photoshop 7 icon disappeared and replaced by script editor

    Photoshop 7.01 on G4 iMac system 10.4.11
    After 6 years continual use of this program, it has suddenly done bad. I went to open the application and the PS icon had changed to a generic one which turned out to be scripting editor. I could open via an existing PS file but not from the actual application icon. I had recently installed the latest security update from Apple, but this may a coincident. I've run Disc Doctor and Disc Warrior, ditched the preferences etc. but the problem remained. I then reinstalled from my original disc, and the script editor icon is still there in place of the PS icon, except that it is blank and therefore will not open at all. Any existing Photoshop files I have now open in Preview.
    I have searched the knowledge base and have not seen a comparable problem
    Has anyone got any ideas?

    >I've run Disc Doctor
    As in Norton's Disk Doctor??? Very, very bad idea,
    Norton is NASTY stuff in OS X. Stay away from anything with the Norton name if you're on any version of OS X, especially do NOT let anything with the Norton name (like Norton Anti Virus, File Saver) ever reside on your computer.
    NAV (Norton Anti Virus) can lead to permanent file damage. Files damaged by NAV are not recoverable. NAV can also prevent many PostScript files from parsing, even if not damaged permanently.
    Disk Doctor
    and Speed Disk are known to cause the kind of directory damage that can lead to kernel panics.
    http://www.macmaps.com/kernelpanic.html
    Another excellent reason to steer clear from all things Norton!
    The kernel panic FAQ is divided by the order of most common occurrences of kernel panics:
    # Directory
    # Drivers
    # Permissions
    # RAM
    1. A directory failure or user accidentally moving .kext files that should be left alone. The directory may fail, due to an accident caused by Norton Utilities or Systemworks, which may at random corrupt a directory even when trying to repair it. Norton Anti-Virus will not do this, but
    Norton Disk Doctor
    and Norton Speed Disk have a history of doing this.

Maybe you are looking for

  • Photoshop CC 2014 file save issue on OS X Server 2.21

    Before we start, I do know that Adobe doesn't officially support saving files to a file server.  However on CC2014 sometimes when we save files they disappear and we are left with a temporary file in the directory.  Wondering if anyone else has seen

  • Why the hell is CC AGAIN telling me I am on a trial version and asking me to login and register?

    Why the hell is CC AGAIN telling me I am on a trial version (I am not and have never been) and asking me to login and register? This happened last year and I thought Adobe had fixed it but it has again been occurring for the past couple of weeks and

  • No BOM explosion for sub-contract purchased materials

    Hello, I have searched google and this forum and have not found any info on this.  Hopefully someone has run across this same situation and can help. We do not want to have a bom explosion happen for externally procured materials (using CU51).  We ar

  • Can't get dreamweaver to open swf files.

    Hello, I am new to dreamweaver and I am having a major problem in trying to edit an existing website. My website was done with flash files swf. and when in the local directory I click on the file I get an error message "Can't find a valid editor for

  • Writing file proving problematic

    Hi, I have a 2D array that I have stored as a string. I have checked it's out put and it looks very much like it should. It is a 2D array of ints representing the solution to a maze, so it looks something like this: 5 1 1 5 1 1 5 5 3 with 5s being le