Regex backreference combined with string - how to separate

Hi, 
I'm doing a replace with a backreference but the backreference is being interpreted as part of the string instead. If I insert a space it is interpreted correctly but I do not want to have a space.
Here's the code:
$regex = '(<add key="Global.LoadBalancer.ServerFarmIPAddresses.CSV"\svalue=")(?:[^"]+)("\s/>)'
$fillerString = '$1127.0.0.1$2'
The expected result should be to change this string:
<add key="Global.LoadBalancer.ServerFarmIPAddresses.CSV" value="10.10.10.10,10.10.10.9,10.128.128.211,10.128.128.111" /> 
And change it to this one:
<add key="Global.LoadBalancer.ServerFarmIPAddresses.CSV" value="127.0.0.1" /> 
But instead it changes it to this:
    $1127.0.0.1" />    
How can I separate the $1 from the Ip address without adding a space?

Put curly braces around the "1" and "2" in the replacement string:
$fillerString = '${1}127.0.0.1${2}'

Similar Messages

  • JSF combined with EJB, how??

    Hi @ll,
    I have been trying for some days to combine my JSF pages with EJB Session Beans, but I haven't really found a working way to do it.
    First, I had my session bean directly as the backing bean for the JSF page, but I read somewhere that this isn't "allowed", so I created a helper bean as managed bean. This is now the backing bean for the jsf page and has as attribute the session bean.
    My helper bean:
    public class ManagedHelperBean {
    @EJB private JDDACReaderBeanRemote reader;
    public JDDACReaderBeanRemote getReader() {
         return reader;
    public void setReader(JDDACReaderBeanRemote reader) {
         this.reader = reader;
    }Part of my faces-config.xml
    <managed-bean>
    <managed-bean-name>helper</managed-bean-name>
    <managed-bean-class>com.company.ManagedHelperBean</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>Part of my jsp page:
    <h:outputText value="#{helper}"/>
    <h:outputText value="#{helper.reader}"/>Now, the first output in the jsp page works, the second one doesn't. Why can't the property reader be accessed?? What is the correct way to combine JSF with EJB?
    Kind regards,
    Wiebke

    Hello,
    I faced the same problem, but on a Weblogic 10 server.
    The problem with Weblogic 10 is, even if it's "supposed" to be a EE5 compliant server, it is not.
    As described here http://e-docs.bea.com/wls/docs100/webapp/annotateservlet.html , there is no Dependency Injection in JSF managed beans:
    The web container will not process annotations on classes like Java Beans and other helper classes.
    But, WL 10 offers DI on Servlets, Filters and Listeners.
    Here is how I solved it (probably not the best way, but it works for me):
    - created a filter with a list of EJB injected (as it works). For every filtered request, set a list of known (enum) as request attributes mapped each to a EJB service:
    public class EJBInjectFilter implements Filter {
    @EJB
    private MyEJBService ejbRef;
    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException,
                   ServletException {
    log.debug("Setting EJB ref into request as attribute ");
              req.setAttribute(ServiceEnum.MY_EJB_SERVICE.toString(), ejbRef);
              chain.doFilter(req, resp);     
    - for every managed bean who needs a service you can do something like:
    (MyEJBService) ((HttpServletRequest) FacesContext.getCurrentInstance().
                   getExternalContext().getRequest()).getAttribute(ServiceEnum.MY_EJB_SERVICE.toString())
    to get a reference to service.
    I agree it is a totally not elegant solution. But why does WL 10 say it's a full JEE5 compliant server, and though does not provide DI for managed beans?
    A drawbacks I could think of is performance slow-down (for every request, apply filter, set list of attributes + references into request) - probably it does take some time.
    Let me know your thoughts.
    Edited by: cosminj on Nov 20, 2007 8:16 AM

  • Problems with String.split(regex)

    Hi! I'm reading from a text file. I do it like this: i read lines in a loop, then I split each line into words, and in a for loop I process ale words. Heres the code:
    BufferedReader reader = new BufferedReader(new FileReader(file));
    String line;
    while ((line = reader.readLine()) != null) {
        String[] tokens = line.split(delimiters);
        for (String key : tokens) {
    doSthToToken();
    reader.close();The problem is that if it reads an empty line, such as where is only an "\n", the tokens table has the length == 1, and it processes a string == "". I think the problem is that my regex delimiters is wrong:
    String delimiters = "\\p{Space}|\\p{Punct}";
    Could anybody tell me what to do?

    Ok, so what do you suggest?I suggest you don't worry about it.
    Or if you are worried then you need to test the two different solutions and do some timings yourself.
    And how do you know the regex lib is so slow and badly written?First of all slowness is all relative. If something takes 1 millisecond vs 4 milliseconds is the user going to notice? Of course not which is why you are wasting your time trying to optimize an equals() method.
    A general rule is that any code that is written to be extremely flexible will also be slower than any code that is written for a specific function. Regex are used for complex pattern matching. StringTokenizer was written specifically to split a string based on given delimiters. I must admit I haven't tested both in your exact scenario, but I have tested it in other simple scenarios which is where I got my number.
    By the way I was able to write my own "SimpleTokenizer" which was about 30% faster than the StringTokenizer because I was able to make some assumptions. For example I only allowed a single delimiter to be specified vs multiple delimiter handled by the StringTokenizer. Therefore my code could be very specific and efficient. Now think about the code for a complex Regex and how general it must be.

  • Iphone ios5..I upgraded to ios5 on my iphone 4 and in the demo video on the Apple website it shows a cute animation screen with the user dragging what appears to be balloons on a string how do you access this screen?

    iphone ios5..I upgraded to ios5 on my iphone 4 and in the demo video on the Apple website it shows a cute animation screen with the user dragging what appears to be balloons on a string how do you access this screen?
    Not sure if this is a game or app or not...it shows nothing about it and explains nothing about it...but it is there on the demo video on the apple website for the add to upgrade to ios 5...it shows the user dragging threads and the little icon monster at the bottom of the screen catches them

    Yea thats a game called "Cut the Rope" and it can be found in the App Store for $0.99 or you can buy the Lite version for free.

  • Regex with strings that contain non-latin chars

    I am having difficulty with a regex when testing for words that contain non-latin characters (specifcally Japanese, I haven't tested other scripts).
    My code:
    keyword = StringUtil.trim(keyword);
    //if(keywords.indexOf(keyword) == -1)
    regex = new RegExp("\\b"+keyword+"\\s*;","i");
    if(!regex.test(keywords))
    {Alert.show('"'+keywords+'" does not contain "'+keyword+'"'); keywords += keyword + "; ";}
    Where keyword is
    日本国
    and keywords is
    Chion-in; 知恩院; Lily Pond; Bridge; 納骨堂; Nōkotsu-dō; Asia; Japan; 日本国; Nihon-koku; Kansai region; 関西地方; Kansai-chihō; Kyoto Prefecture; 京都府; Kyōto-fu; Kyoto; Higashiyama-ku; 東山区; Places;
    When the function is run, it will alert that keywords does not contain keyword, even though it does:
    "Chion-in; 知恩院; Lily Pond; Bridge; 納骨堂; Nōkotsu-dō; Asia; Japan; 日本国; Nihon-koku; Kansai region; 関西地方; Kansai-chihō; Kyoto Prefecture; 京都府; Kyōto-fu; Kyoto; Higashiyama-ku; 東山区; Places; " does not contain "日本国"
    Previously I was using indexOf, which doesn't have this problem, but I can't use that since it doesn't match the whole word.
    Is this a problem with my regex, is there a modifier I need to add to enable unicode support or something?
    Thanks
    Dave

    ogre11 wrote:
    > I need to use refind to deal with strings containing
    accented characters like
    > ?itt? l?su, but it doesn't seem to find them. Also when
    using it with cyrillic
    > characters , it won't find individual characters, but if
    I test for [\w] it'll
    > work.
    works fine for me using unicode data:
    <cfprocessingdirective pageencoding="utf-8">
    <cfscript>
    t="Tá mé in ann gloine a ithe;
    Nà chuireann sé isteach nó amach
    orm";
    s="á";
    writeoutput("search:=#t#<br>for:=#s#<br>found
    at:=#reFind(s,t,1,false)#");
    </cfscript>
    what's the encoding for your data?

  • In the iMovie 11 event library, how can I get the iPhoto video clips to combine with my camcorder pics listed below and in chronological order?

    In the iMovie 11 event library, how can I get the iPhoto video clips to combine with my camcorder pics listed below and in chronological order?

    Try forcing iPhoto to load the Library on the External Hard drive by launching it while holding down the Option key. Choose the Library on the External HD, and quit iPhoto, see if iMovie can see the Library with the iPhoto Videos contained inside.

  • When I burn dvd in iPhoto, it comes out with original photo plus separate close up photos of each face in original photo.  How do I get it to stop doing that?

    When I burn dvd in iPhoto, it comes out with original photo plus separate close up photos of each face in original photo.  How do I get it to stop doing that?

    I am reading this post in the iphoto for iOS forum. The iPad does not burn photos to a DVD. Perhaps you'll get some assistance if you posted in th general iPhoto forum.

  • How to separate an object with a 3d effect

    How to separate an object with a 3d effect
    Hi, I have outlined some text and applied a 3d effect but now I want to separate each letter so I can adjust the colour on the face of the letter with the colour on the extruded part.
    I am sure it is probably straight forward but could do with a little help!
    Thanks

    I think what the OP wants to do is to keep the extruded part the same color and change the face of the letters to different colors. And he/she did mention that the text is outlined.
    If that's the case, I can think of two things to do if you want to keep the 3D effect live (i.e., unexpanded).
    1. You could apply a stroke to the outlined text, in the color you want for the extruded part. Then just change the fills individually (Tip: view in Outline mode and use the Group Selection tool to select each letter).
    2. If you don't like how the stroke looks on the letters, make all the letters the same color — the color you want for the extruded part. Then make a copy of this group of letters. Select the copy, then click in the Appearance panel to to edit the 3D effect. Put the Extruded Depth at Zero. Now chnage the colors to your liking, then align them with the original. Interestingly, you can't just use the Align functions, you have to eyeball it.

  • 'fn' key shows desktop (not in combination with f11). How to turn this off?

    iMac 21.5-inch, Late 2012
    OS X Yosemite 10.10.2
    Whenever I press the 'fn' key (standalone) key it shows my desktop, which it makes it difficult for me to use this key in combination with the f1-f12 keys. I had a similar issue on my Macbook Air, which was resolved by changing my keyboard to the correct input source and double checking that no shortcuts had been installed for the keyboard. When I realised that my iMac had the same problem I went through the same steps but nothing changed this time.
    I've restored all shortcuts to default and made sure that my keyboard input source is one that matches my wireless keyboard.
    Any ideas on how to stop the 'fn' standalone key from showing my desktop?

    Hi nbmm000,
    I see that you are experiencing an issue with the function key on your keyboard. While I am sure you have already seen this step, it has not been mentioned in your post, so I thought I would mention it as a troubleshooting step:
    How to change the behavior of function keys on your Mac - Apple Support
    http://support.apple.com/en-us/ht3399
    Thanks for coming to the Apple Support Communities!
    Cheers,
    Braden

  • How to combine with JSP??

    I am a newble to Flex 2
    I am confuse that how can i combine with JSP to send and
    retrive data with mysql ??
    I have seen some examples that juz make a linking with jsp
    which is printed to XML format for data extracting.
    But how to insert and retrive data dynamically?
    Some people say that it can directly programming mxml in .jsp
    by importing mxml tag library....and finally complie on the web
    server. But .... Wazz is the reason i have to buy flex builder.....
    Are there any way i can program with jsp in flex 2 ?
    i am sorry for my poor english
    any help will be highly appreciated

    Eran,
    Can you elaborate on what you're looking for?
    UCM comes with a number of sample custom element forms. These forms are leveraged within a pretty strict context of the site studio contributor. The primary api is javascript based.
    I don't believe you would be restricted on the types of custom element forms you can create if you're implementing into a jsp/x site. I believe the issue is mostly dependent on how you're calling the SS contributor.
    -ryan

  • HT201077 When my wife creates a Shared stream on her account it says it came from me with her Account. She is logged into her own separate Apple ID on both her phone and iPad. Any ideas how to separate?

    When my wife creates a Shared stream on her account it says it came from me with her Account. She is logged into her own separate Apple ID on both her phone and iPad. Any ideas how to separate?

    There are a lot of posts in the forums today with people having problems with iMessage.   There was also a published outage yesterday, so it's possible there are still some issues that may be impacting you both.
    I would just wait it out - I'm sure it will be sorted out soon.

  • How to separate two contact with same name

    Hi, anyone knows how to separate two contacts with same name in Contacts?  Actually they are two persons from two gmail contacts with same name but different contact numbers, different emails....etc, but Contacts assume they are same person and merge them as one!

    FG,
    In Lion, you have the File > Duplicate option. You will then have two copies of your document open, and the one on top will have the temporary filename "OriginalFileName copy", and your next responsibility is to File > Save (or Command-S) and rename the duplicate. At this point, you edit the copy's name, to perhaps ...copy 1, or whatever you wish. The document you had open when you initiated the File > Duplicate will still be there on your screen, waiting for you to Close it or continue editing.
    Jerry

  • How to run a .bat file with string arguments?

    Hi,
    I have a problem in running a .bat file with string arguments
    - the file is XPathOverlap.bat with 2 stringarguments like: "/a" and "//a"
    - the cmd: c:\Downloads>XPathOverlap "//a" "/a" works fine.
    - here is my code:
    public static void test(){
         try{
              String loc1 = "//a";
              String loc2 = "/a";
              String[] cmdarray = {"c:\Downloads\XPathOverlap", loc1, loc2};
              Process p = Runtime.getRuntime().exec(cmdarray);
              p.waitFor();
              System.out.println("Exit Value: "+p.exitValue());
              //code to print command line replies
              InputStream cmdReply = p.getInputStream();
              InputStreamReader isr = new InputStreamReader(cmdReply);
              BufferedReader br = new BufferedReader(isr);
              String line = null;
              while((line=br.readLine())!=null){
                   System.out.println(line);
         }catch(Throwable t){
              t.printStackTrace();
    How can i run this bat file with 2 string arguments?

    Hi,
    thanks thats good and helpfully
    so this code works:
    String loc1 = "\"/a\"";
    String loc2 = "\"//a\"";
    String path = System.getenv("MuSatSolver");
    String[] cmdarray = {"cmd.exe","/C",path+"XPathOverlap.bat", loc1, loc2};
    Process p = Runtime.getRuntime().exec(cmdarray);
    p.waitFor();
    System.out.println("Exit Value: "+p.exitValue());
    InputStream cmdErr = p.getErrorStream();
    InputStreamReader isrErr = new InputStreamReader(cmdErr);
    BufferedReader brErr = new BufferedReader(isrErr);
    String line2 = null;
    while((line2=brErr.readLine())!=null){
         System.out.println("Error: "+line2);
    but now i have another problem, this is the output:
    Exit Value: 0
    Error: java.lang.NoClassDefFoundError: fr/inrialpes/wam/treelogic/_xml/XPathOverlap
    Error: Exception in thread "main" The Exit value is 0, so the process terminates normally.
    I have tested this bat file in cmd and there it works correctly.
    Why do i get this error message?

  • How can I use the DAQMX in combination with a FIREWIRE MIO?

    We had problems in using DAQMX in combination with a NI FIREWIRE MIO Acquisition Card (according to an explanation of a NI-Consultant). Is there a way to solve that problem?

    NI's manual claims there will be DAQmx support for firewire in the future. I hope so too.
    Best,
    Davy

  • How to not index characters combined with numbers?

    According to the Oracle Text Reference (10g or 11g) regarding a "stopclass", currently, only the NUMBERS class is supported and it is not possible to create a custom stopclass. So is there another way to not index text that contains characters combined with a number (such as "123ABC" or "ABC123")? If the text contains a number (anywhere in it) I don't want it indexed. Otherwise, I end up with a lot of junk representing 90% of my index and causes a maintenance pain...Essentially going from 300K rows in the index table to over 13 Million.

    The only thing that I can think of is to use a user_datastore with a procedure that loops through each token in the row, eliminating those that have numbers. Please see the demonstration below.
    SCOTT@orcl_11gR2> CREATE TABLE test_tab
      2    (test_col  VARCHAR2 (60))
      3  /
    Table created.
    SCOTT@orcl_11gR2> INSERT ALL
      2  INTO test_tab VALUES ('worda abc123 wordc')
      3  INTO test_tab VALUES ('worda 123abc wordc')
      4  INTO test_tab VALUES ('def456 wordb wordc')
      5  INTO test_tab VALUES ('worda wordb 789ghi')
      6  SELECT * FROM DUAL
      7  /
    4 rows created.
    SCOTT@orcl_11gR2> CREATE OR REPLACE PROCEDURE test_proc
      2    (p_rowid IN           ROWID,
      3       p_clob     IN OUT NOCOPY CLOB)
      4  AS
      5    v_clob            CLOB;
      6    v_token            VARCHAR2 (100);
      7  BEGIN
      8    SELECT test_col || ' '
      9    INTO   p_clob
    10    FROM   test_tab
    11    WHERE  ROWID = p_rowid;
    12    WHILE INSTR (p_clob, '  ') > 0 LOOP
    13        p_clob := REPLACE (p_clob, '  ', ' ');
    14    END LOOP;
    15    WHILE LENGTH (p_clob) > 1 LOOP
    16        v_token := SUBSTR (p_clob, 1, INSTR (p_clob, ' '));
    17        IF v_token = TRANSLATE (v_token, '1234567890', '        ') THEN
    18          v_clob := v_clob || v_token;
    19        END IF;
    20        p_clob := LTRIM (SUBSTR (p_clob, INSTR (p_clob, ' ')));
    21    END LOOP;
    22    p_clob := v_clob;
    23  END test_proc;
    24  /
    Procedure created.
    SCOTT@orcl_11gR2> SHOW ERRORS
    No errors.
    SCOTT@orcl_11gR2> EXEC CTX_DDL.CREATE_PREFERENCE ('test_store', 'USER_DATASTORE')
    PL/SQL procedure successfully completed.
    SCOTT@orcl_11gR2> EXEC CTX_DDL.SET_ATTRIBUTE ('test_store', 'PROCEDURE', 'test_proc')
    PL/SQL procedure successfully completed.
    SCOTT@orcl_11gR2> CREATE INDEX test_idx
      2  ON test_tab (test_col)
      3  INDEXTYPE IS CTXSYS.CONTEXT
      4  PARAMETERS ('DATASTORE test_store')
      5  /
    Index created.
    SCOTT@orcl_11gR2> SELECT token_text FROM dr$test_idx$i
      2  /
    TOKEN_TEXT
    WORDA
    WORDB
    WORDC
    3 rows selected.
    SCOTT@orcl_11gR2>

Maybe you are looking for

  • Imac g5 Rev A - Boots, dies after login, finder, etc.

    My usual morning ritual at the computer and noticed the computer was awaiting a log-in, sign of a reboot. I rebooted and played, worked for 45 minutes or so, everything ok. Later as the wife was using the machine later in the morning, it began reboot

  • Moving movie files from Windows to iMovie

    Hello, I have recently purchased a Macbook and have a number of home movies on VHS I want to edit and convert to DVD using iMovie. I do not have a analog to DV device to connect to my Macbook, but I do have one installed in my Win/XP machine. I would

  • Rights on URL items in a content area

    Hi, Ok, so now I have my query to retrieve the main URL items (top level branches) in a content area for my treeview. This is the query: SELECT IT.Name, IT.MasterThingId, IT.ParentId, URL.Url, COUNT(IT2.Name) Subs FROM WWV_THINGS IT, WWSBR_URL$ URL,

  • Problem with children of HtmlDataTable

    Hi, I'm trying to highlight a row in a HtmlDataTable by clicking on it but ran into a confusing problem. I can access the table and when I fetch the children I get as many as the table has columns, so far so good. But when accessing the children (or

  • How to store images in database and retrieve them back to page?

    Well I don't know how to store an image file to a database (say MSSQL) from the JSP and retrieve it back whenever needed and put it on the JSP page? Please help me.