Using Regex to find a string

Is it viable to use regular expressions with Search "Specific Tag" (i.e.script) "With Attribute" (i.e. src) and "=" a regex string rather than an exact search term?  The Find / Replace tool seems to prevent a simple wildcard find (i.e. "searchter* for searchterm) Any insight would be appreciated.

uneAaron wrote:
I'm trying to replace a script source value for all instances where the value contains the string "/bbcswebdav/xid-144702_1", where the string "xid-" is followed by a different numerical value in each instance.
The regex for finding that string is:
\/bbcswebdav\/xid\-[\d_]+
The numerical value contains an underscore, so the final section ( [\d_]+ ) uses a range that selects one or more numbers and/or underscores.
Perhaps as important as identifying what you want to find is specifying how you want to replace it. Regexes can have capturing groups that can be used in the Replace field to simplify matters.

Similar Messages

  • Using Regex to search strings......

    Hey guys,
    I'm trying to scan an html file for specific strings. Basically, I just store the entire html file as a one big long string and then use a regex to scan the string for specific keywords that I am looking for. However, I am not all that familiar with regular expressions in java, and, although I have spent a considerable amount of time reading over the tutorials, I can't seem to get my regular expression to produce the results that I want.
    +More specifically, what I am trying to scan the html string for is a keyword preceded by a non-alphanumeric character([/W] and followed by a non-alphanumeric character. Also, since the keywords generally represent country names, state names, state abbreviations, city names, and the like.....I really want to make the scan case-insensitive to the case format of the keyword except in the case that the keyword is an abbreviation (i.e., CA, IN, NY,etc. since making this case-insensitive would pick up a lot of garbage, especially in cases like: IN)+_.* As of right now, this is what I am using for my regex(and the results are all over the place):
    *String regex = "[/W]+"+"(?i)"+keyword+"[/W]+";*
    This just seems wrong! I've played around with it and, lets just say, the results have generally gotten worse. Does anyone have any ideas on how I should correctly format the regex to achieve the goal explained above?? Any and all help would be greatly appreciated. Thanks.

    A technique I find very useful in writing complex regex's is to split the regex into its parts and work on just the one part at a time. This helps me to easily see that the components match exactly what I think I am matching. Once I have every individual part working it is very easy to join them to create the entire match.
    Something like...
    String keywordRegex = "";
    String nonAlphaCharRegex = "";
    //..etc. etc
    String fullRegex = keywordRegex + "whateverIwantToMatchBetween" + nonAlphaCharRegex + ...

  • Extract the numbers in string using regex

    Hi,
    How to extract the numers in string using regex?.
    Already i tried split up the string using [\\s]
    For ex: "Uting Tatk and Window Panet 15"
    it gives the ans 15.
    if the string is
    For ex: "Uting Tatk and Window Panet 15 New!"
    i can't find the number.
    so plz give me some idea to get the number frm String.
    Thanks

    I am developing a java project to extract Table of
    content in a particular
    PDF.
    i extracted all topics.
    then i want 2 extract page number from dat extracted
    TOC.
    if the TOC ends with number then i can easily find
    out the number
    but in vain if the TOC ends with like this
    "Uting Tatk and Window Panet 15 New!".
    i could n't find the page number.What will you do if it says:
    "15 ways to find topics 42 new"

  • DW CS5 - Find/Replace using RegEx

    Hello, everyone.
    I am working on some inherited code, and the previous people used some named anchors; some are properly closed, most are not.  There are over 100 of them that I don't want to correct manually.
    Examples:
    <a name="this">
    <a name="that"></a>
    <a name="other">
    <a name="org"> </a> <-- notice the space between
    I am trying to use RegEx in the Find and Replace so I can correct these to all being closed.  Here is the string I'm looking for:
    <a name="([^"]*)["]>[^\w{1,}<\/a>]
    But this is not finding any of the named anchors.  I did have the same thing, minus the [^\w{1,}<\/a> part, but it found ALL the named anchors, closed and not-closed.
    Also, I have (for replacement) <a name="$1"/>, but am not sure if this will properly replace.  Suggestions?
    ^_^

    Anyone?

  • Search given string array and replace with another string array using Regex

    Hi All,
    I want to search the given string array and replace with another string array using regex in java
    for example,
    String news = "If you wish to search for any of these characters, they must be preceded by the character to be interpreted"
    String fromValue[] = {"you", "search", "for", "any"}
    String toValue[] = {"me", "dont search", "never", "trip"}
    so the string "you" needs to be converted to "me" i.e you --> me. Similarly
    you --> me
    search --> don't search
    for --> never
    any --> trip
    I want a SINGLE Regular Expression with search and replaces and returns a SINGLE String after replacing all.
    I don't like to iterate one by one and applying regex for each from and to value. Instead i want to iterate the array and form a SINGLE Regulare expression and use to replace the contents of the Entire String.
    One Single regular expression which matches the pattern and solve the issue.
    the output should be as:
    If me wish to don't search never trip etc...,
    Please help me to resolve this.
    Thanks In Advance,
    Kathir

    As stated, no, it can't be done. But that doesn't mean you have to make a separate pass over the input for each word you want to replace. You can employ a regex that matches any word, then use the lower-level Matcher methods to replace the word or not depending on what was matched. Here's an example: import java.util.*;
    import java.util.regex.*;
    public class Test
      static final List<String> oldWords =
          Arrays.asList("you", "search", "for", "any");
      static final List<String> newWords =
          Arrays.asList("me", "dont search", "never", "trip");
      public static void main(String[] args) throws Exception
        String str = "If you wish to search for any of these characters, "
            + "they must be preceded by the character to be interpreted";
        System.out.println(doReplace(str));
      public static String doReplace(String str)
        Pattern p = Pattern.compile("\\b\\w+\\b");
        Matcher m = p.matcher(str);
        StringBuffer sb = new StringBuffer();
        while (m.find())
          int pos = oldWords.indexOf(m.group());
          if (pos > -1)
            m.appendReplacement(sb, "");
            sb.append(newWords.get(pos));
        m.appendTail(sb);
        return sb.toString();
    } This is just a demonstration of the technique; a real-world solution would require a more complicated regex, and I would probably use a Map instead of the two Lists (or arrays).

  • How To Color a Text string using Regex (java.util.regex)

    Hello,
    How can I color a text string using regex class in 1.4?

    Yes, did you notice it said something about incredibly vague functionality?
    Let me break it down for you
    > How can I color a text string
    Strings do not have color... You can color a component (a label, a button), but you can't color a string
    > using regex class in 1.4?
    Using a regular expression? How would a regular exression color anything? Do you have embedded color codes? Are you searhing a string for some secret word?
    What are you talking about?

  • Use REGEXP_INSTR to find a text string with space(s) in it

    I am trying to use REGEXP_INSTR to find a text string with space(s) in it.
    (This is in a Function.)
    Let's say ParmIn_Look_For has a value of 'black dog'. I want to see if
    ParmIn_Search_This_String has 'black dog' anywhere in it. But it gives an error
    Syntax error on command line.
    If ParmIn_Look_For is just 'black' or 'dog' it works fine.
    Is there some way to put single quotes/double quotes around ParmIn_Look_For so this will
    look for 'black dog' ??
    Also: If I want to use the option of ignoring white space, is the last parm
    'ix' 'i,x' or what ?
    SELECT
    REGEXP_INSTR(ParmIn_Search_This_String,
    '('||ParmIn_Look_For||')+', 1, 1, 0, 'i')
    INTO Position_Found_In_String
    FROM DUAL;
    Thanks, Wayne

    Maybe something like this ?
    test@ORA10G>
    test@ORA10G> with t as (
      2    select 1 as num, 'this sentence has a black dog in it' as str from dual union all
      3    select 2, 'this sentence does not' from dual union all
      4    select 3, 'yet another dog that is black' from dual union all
      5    select 4, 'yet another black dog' from dual union all
      6    select 5, 'black dogs everywhere...' from dual union all
      7    select 6, 'black dog running after me...' from dual union all
      8    select 7, 'i saw a black dog' from dual)
      9  --
    10  select num, str
    11  from t
    12  where regexp_like(str,'black dog');
           NUM STR
             1 this sentence has a black dog in it
             4 yet another black dog
             5 black dogs everywhere...
             6 black dog running after me...
             7 i saw a black dog
    5 rows selected.
    test@ORA10G>
    test@ORA10G>pratz
    Also, 'x' ignores whitespace characters. Link to doc:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/conditions007.htm#i1048942
    Message was edited by:
    pratz

  • Find exact string using formula (excel)

    I'm trying to use FIND statement to find multiple strings in the context of a larger formula. The original formula I'm basing it off of is as follows:
    =IF(ISNUMBER(FIND("INC",A1))," ","Y")
    Obviously, this yields a Y if it finds whatever text in " ". However, I have many strings for which I'd like to check and they need to be exact; ie when I search INC and inc, I do not want Inc to be counted. So, I tried the following formulas.
    =IF(ISNUMBER(FIND(OR("INC",inc"),A1))," ","Y")
    =IF(SUM(COUNTIF(A1,"* INC*","* inc*}))," ","Y")
    The second one works best, but it also counts "Inc" as a match. Any suggestions?

    bk284,
    Well you've posted to the wrong forum as this forum is dedicated to questions/issues about customizing and programming Microsoft Project, a planning and scheduling application. However, your question is simple enough that I'll just take a shot at helping.
    Try the LOWER function, it converts a text string to lower case so the upper case, lower case issue goes away.
    If this answered your question, please mark it as the answer.
    In the future, for Excel related questions, use this forum: http://social.msdn.microsoft.com/Forums/office/en-US/home?category=officedev
    John

  • Regex excluding a certain string

    Hi
    I have a question about how to search the strings that are in between a "start" and an "end". The results should not contain the word " cat ". All the strings with the format "start xxxxx yyyy end" that do not contain the word " cat " are valid. That is, the string "start XXX cat YYYY BBB end" should be rejected.
    I am using the regex "start(.*?)end" to find all the strings that start with "start" and ending with "end".
    The expression [^cat] can be used to negate the characters "cat" in any sequence (atc,act...). I want only to negate the sequence "cat". Any ideas about how to exclude the strings with "cat"in an effective way???
    Regards

    When you want to exclude whole
    sequences of characters, you have to use negative
    lookahead:
      String regex =
    "start\\s+((?!cat\\s+)\\S+\\s+)*?end";
    How does this regex work and where the "next search starts" in case the match fails because the string " cat " was found.
    We assume that there is a string "..startXXXVVVFF CC CAT xxx end......."
    This regex searches for the string "start" (in position a). When it finds "start" it starts "looking ahead" for the occurrence of " cat " (position a + 10). The string "end" is in position a+20. That is, it will find the string " cat " before it finds "end". It will discard the match. After discarding the "match" where does the regex starts searching for a new "start"?
    Does it start searching for a new match (sartXXXend)direct after the previous "start" (that is, at position a+1). Or does it starts searching after a new match after the previous "end" (at position a+21)????

  • How to find a string in SAP code

    Hello,
    Does anyone here know how I can find a string inside the SAP code efficiently? I tried finding a custom table name using the Where-used list feature but the results doesn't show the complete/correct results. It missed some user exits where the table name was also used.
    Please help

    Hello Jimmy,
    You can try what Krishna has said there is one more way that is
    goto trxn SE12,
    enter Z* in the table name field,
    it will give a popup box with all the Ztables found in your system...you can find your table maybe it is a little tedious job
    Sravani

  • How to find a string inside Excel table

    Hi,
    I am trying to find a string inside Excel table, and it does not work. Please see attached figure. I use the find Invoke Node and do not get anthing.
    Please help
    Attachments:
    find_excel.JPG ‏21 KB

    See attached files.
    Thanks,
    David
    Attachments:
    Excel_table.xls ‏15 KB
    Read_XL.vi ‏42 KB

  • How do I use the event.target.name String with an external dispatchEvent?

    ...I hope the title question makes sense...
    On my stage I have an externally loaded SWF with a button. When clicked the button dispatches an event to the main stage.
    On the main stage a listener then loads an SWF into a loader called gallery.
    The gallery loader is also being shared by buttons on the main stage which use the event.target.name String to call in SWFs with corresponding names.
    I am using Tweens to fade-out and -in content to the gallery when a button is pressed.
    Loading the SWFs was working until I tried to create a universal button function for the dispatchEvent buttons...
    The problem I have is that I don't know how to define the String to tell the newSWFRequest where to find the SWF when triggered by the external buttons.
    (I may be doing this all wrong... but figured the best way to load an SWF on to the main stage from an external SWF was by using dispatchEvent??)
    My code triggers the Event and the gallery loader fades out, but then it cannot find the new SWF:
    Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.
    Please can someone help me understand the way to make the String point in the right direction? (I think the only errors are in bold below)
    Code:
    var myTweenIn2:Tween;
    var myTweenOut2:Tween;
    var nextLoadS2:String;
    // Listen for external event dispatched from external btns
    addEventListener("contactStage", btnClickExtrnl);
    function btnClickExtrnl(e:Event):void {
    nextLoadS2 = ?????
    myTweenOut2=new Tween(gallery,"alpha",None.easeOut,gallery.alpha,0,0.2,true);
    myTweenOut2.addEventListener(TweenEvent.MOTION_FINISH,tweenOutCompleteF2);
    // Btns Universal function
    function tweenOutCompleteF2(e:TweenEvent){
    myTweenOut2.removeEventListener(TweenEvent.MOTION_FINISH,tweenOutCompleteF2);
    myTweenOut2=null;
        var newSWFRequest:URLRequest = new URLRequest("swfs/" + nextLoadS2 + ".swf");
    myTweenIn2 = new Tween(gallery, "alpha", None.easeOut, gallery.alpha, 1, 0.2, true);
        gallery.load(newSWFRequest);
        gallery.x = Xpos;
        gallery.y = Ypos;
    Thank you.

    That works – thank you!
    I'm now using this code to fade in each of the SWFs:
    function contactStage(e:MouseEvent):void {
        var newSWFRequest:URLRequest = new URLRequest("swfs/"+e.currentTarget.name+".swf");
        myTweenIn = new Tween(gallery,  "alpha", None.easeOut, 0, 1, 0.2, true);
        gallery.load(newSWFRequest);
        gallery.x = Xpos;
        gallery.y = Ypos;
    But I cannot add the fade out function. I have amended the above code to create:
    var myTweenOutX:Tween;
    var myTweenInX:Tween;
    function contactStage(e:MouseEvent):void {
    myTweenOutX=new Tween(gallery,"alpha",None.easeOut,gallery.alpha,0,0.2,true);
    myTweenOutX.addEventListener(TweenEvent.MOTION_FINISH,tweenOutCompleteFX);
    function tweenOutCompleteFX(e:TweenEvent){
    myTweenOutX.removeEventListener(TweenEvent.MOTION_FINISH,tweenOutCompleteFX);
    myTweenOutX=null;
        var newSWFRequest:URLRequest = new URLRequest("swfs/"+e.currentTarget.name+".swf");
    myTweenInX = new Tween(gallery,  "alpha", None.easeOut, 0, 1, 0.2, true);
        gallery.load(newSWFRequest);
        gallery.x = Xpos;
        gallery.y = Ypos;
    But get this error:
    ReferenceError: Error #1069: Property name not found on fl.transitions.Tween and there is no default value.
    at ACOUSTIC_fla::MainTimeline/tweenOutCompleteFX()[ACOUSTIC_fla.MainTimeline::frame1:110]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at fl.transitions::Tween/set time()
    at fl.transitions::Tween/nextFrame()
    at fl.transitions::Tween/onEnterFrame()
    Where am I going wrong?

  • PowerShell script to find a string of characters in office documents in Doc Libraries and List Item attachments?

    Hi there,
    For SharePoint 2010 site - Does someone have the PowerShell script to find a string of characters in Office/Word/Excel/PDF documents in document libraries or the ones attached to List Items?
    Thanks so much in advance.

    Hi,
    According to your description, my understanding is that you want to find some specific string character in list items using PowerShell Command.
    $w = Get-SPWeb "http://devmy131"
    $l = $w.GetList("http://devmy131/lists/fieldslist");
    $i = $l.Items[0]["Title"].ToString();
    if ($i -like '*document*')
    Write-Host "Title contains document character" $i;
    More information:
    PowerShell -contains -like
    Thanks
    Best Regards
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • [AS] Find a string of words in text

    Hello - hopefully someone can help as I'm now stuck on this. I want to be able to find a specific string of words within a text frame, though I want to be able to do this without using the Find Text Preferences approach.
    I can get it to work if i am just finding one word, but if there is more than one word it doesn't work.
    For example this works (given a text frame with text in that contains the word Example):
    tell application "Adobe Indesign CS5"
    tell active document
    set mybox to selected
      tell mybox
       set myfind to object reference of every word whose contents = "Example"
      end tell
    end tell
    end tell
    However the same does not work (searching for "The Example", which is two words)
    tell application "Adobe Indesign CS5"
    tell active document
    set mybox to selected
      tell mybox
       set myfind to object reference of every word whose contents = "The Example"
      end tell
    end tell
    end tell
    What i can't figure out is the correct phrasing for finding a string of words, i guess i should not be looking for the object reference of WORD, but nothing else i've tried seems to work. Many thanks for any help

    I think what John has said is correct… I only had a quick look in the dictionary terms. Without find/change the closest you may get is line or paragraph after that you would need to manipulate the line/para contents further… Word by definition I would think can't contain space but is encapsulated in space bar first/last…
    tell application "Adobe InDesign CS5"
    tell active document
    tell story 1
    set myfind to object reference of every word whose contents = "Example"
    end tell
    show text first item of myfind
    end tell
    end tell
    This would show the line you can then break down further…
    tell application "Adobe InDesign CS5"
    tell active document
    tell story 1
    set myfind to object reference of every line whose contents contains "For Example"
    end tell
    show text first item of myfind
    end tell
    end tell

  • Parse html (a href) using regex

    Hello,
    i would like to extract all the urls from a website that are included in < a href=" parse string">
    I have already the regex which is
    String regex = "< *a.*href *= *['|\"]";
    May you please advise me which method in Pattern or Matcher classes shall i use in order to take as output
    *only* the url inside the " " marks?
    I have already tried end and start methods which return the indexes, but i don't get the desirable result.
    Thanks, in advance
    P.S.Also, i have already tried to use HtmlParser but i prefer to use regex cause i found a difficulty in it.

    Please continue in your original thread.
    [http://forums.sun.com/thread.jspa?threadID=5363751]

Maybe you are looking for

  • Error while posting payroll results to FI

    Hi, I am running India Payroll on ECC 6.0. I am getting the following error while generating simulation document through Posting Run. Error in document: HRPAY 0000000060 WPRCLNT100 Text Not Found. Message Number: ZKV 000 Variable: Payroll run is succ

  • Moving iWeb from desktop to laptop

    I need to transition iWeb from my desktop iMac to my Macbook as I'm hitting the road for a few months. Ideally I'd like to be able to open a synced version of iWeb on both machines that let me use either to access and update the same website... But f

  • Iphone4s

    After updating my iphone 4s the battery goes flat in less than one day with minimal use. I have checked to make sure nothing is left open in the phone. Am I missing some thing???

  • ADT error "File [file] is not relative to directory [output]"

    Has anybody come accross this error before when adding files to include to via ADT? For example: adt -package -target ipa-test -storetype pkcs12 -keystore my.p12 -storepass mypass -provisioning-profile my.mobileprovision my.ipa my-app.xml my.swf icon

  • Update geometry of a cylinder

    Hi, There is a way to update the geometry of a cylinder (radius, length) ? There is nothing about on javadoc. It's only possible to get the shape... Thanks. Edit : i will looking on http://aviatrix3d.j3d.org/javadoc/org/j3d/renderer/aviatrix3d/geom/C