RegEx: find() and group() issue...

Hi,
In the code below, I use the find() method to search the first occurence of a match and then group(1) to retrieve that match if the find() method returns true.
The problem is that the find() method returns true and the group(1) throws an ArrayOutOfBoundException :(
Here is the RegEx code I use:
  String value = "${local.production}\\makeresults\\repository";
  Matcher matcher = Pattern.compile("\\$\\{.*\\}").matcher(value);
  if (matcher.find()) {
    System.out.println(matcher.group(1));   // throws an ArrayOutOfBoundException
Got this output:
Exception in thread "main" java.lang.IndexOutOfBoundsException: No group 1
  at java.util.regex.Matcher.group(Matcher.java:463)
  at Test2.main(Test2.java:28)Have I made any mistakes?
Thanks in advance for your help.
Best regards,
Serge.

You shall use group() without parameter to get complete sequence.
Only capturing groups (between parenthesis) are indexed (from left to right, starting at one.)
Here you don't have capturing group (and that's why it says No group 1), and it seems that you need the entire pattern, so you need the group() method.
Matcher
Tim - Actually, you can also use group(0) ...

Similar Messages

  • Find and Replace Issue Help Requested.

    Hi all. I've been digging around for a couple of days and
    can't seem to figure this one out. For starters, I have already
    looked at the Regular Expression syntax and tried the MS word
    clean-up option, but no luck. We have about 1,500 pages of content.
    They are in DNN, so the pages are created dynamically.
    Unfortunately, the page content was written in Word and then dumped
    in DNN. We are trying to clean up the pages. We are grabbing the
    content from Dot Net Nuke and putting it into Dreamweaver 8.0.2.
    Then we are manually cleaning out things like:
    <?xml:namespace prefix = o ns =
    "urn:schemas-microsoft-com:office:office" />
    and
    <P class=MsoNormal style="MARGIN: 0in 0in 0pt"
    align=left>
    We are using the Find and Replace funtion in Dreamweaver to
    clean out these commands, but I know from the documentation, there
    is an easier way to clean these pages.
    Bottom Line: Since the pages are dynamically built, I know I
    have to grab the page content and put it in Dreamweaver manually
    and then put it back in DNN, but I am trying to find a way (using
    Regular Expressions or something) to look for all the little
    variances of MSO, <?XML, etc. in a straight shot. I would like
    to find a way to use a wild card to look for all tags that have MSO
    or Microsoft or ?XML in them and then replace them with a null
    value. From what I can tell, the Find would have to use a wildcard
    because the advanced find features don't carry what I am looking
    for. Something like Find \<?xml * [<-wildcard] to \> to
    grab the entire tag. The Find tag command doesn't work because the
    tags I need aren't listed. Also, because the content is dynamic, I
    can't do a Fins and Replace against the entire site for these
    commands, but it would be nice to "Find" all of these items with a
    single pass since the "Replace" value is always null.
    The wildcard syntax and multiple Find instances are the main
    questions. The wildcards seem to be character or space specific.
    Sorry for the long explanation - I just don't want to waste
    anyone's time typing responses to things I've already tried to do.
    Thanks in advance for any help. This is my first time back in
    the forums in about 4 years.

    sadamec1 wrote:
    > Well David, you Findmaster - it worked! (At least it
    found and highlighted the
    > code). Now, I need to dig through what you sent me and
    compare it against my
    > regular expression definitions to find out how to grab
    the rest of these
    > phrases. You're the best. Thank you!
    Glad that it did the trick. Just to help you understand what
    I did,
    there are two main sections, as follows:
    <\?xml[^>]+>
    and
    <[^>]+(?=class=Mso)[^>]+>
    They are separated by a vertical pipe (|), so they simply act
    as
    alternatives.
    The first one searches for <?xml followed by anything
    except a closing
    bracket until it reaches the first closing bracket.
    The second one is more complex. It begins with this:
    <[^>]+
    This simply looks for an opening bracket followed by anything
    other than
    a closing bracket. What makes it more intelligent is the next
    bit:
    (?=class=Mso)
    This does a forward search for "class=Mso". It's then
    followed by this
    again:
    [^>]+>
    That finds anything except a closing bracket followed by a
    closing bracket.
    The bit that you need to experiment with is (?=...). It's
    technically
    called a "forward lookaround". The effect is that the second
    half of the
    regex finds <....class=Mso....>.
    David Powers
    Adobe Community Expert
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    http://foundationphp.com/

  • Find and Replace issue

    Hello all.
    I must have clicked something I should not have.
    In the past I could search for a string ( $username ) and no issues at all...it would find them.
    Now if I have the dollar sign ( $ ) in the find section it will find nothing.  When there are many entries for it to find.
    If I remove the $ it will find all the username entries.
    Thank you for time

    Here are my settings in the FaR box
    Find in: Current Document
    Search: Source code
    Options: Match case  **checked
               : Use regular expression  **checked
               : Match whole word  **unchecked
               : Ignore whitespace **Greyed out and unchecked
    Thank you

  • Finder and iTunes issues.

    This past week or so, iTunes has been force booting itself at seemingly random times.
    This has been causing me issues when I am working on video or audio projects, as when iTunes boots it eats almost all of my RAM and causes most of my programs to lock up, even if only temporarily.
    When this happens Finder eventually loses connection to my LAN and ejects my external hard drives. When I try to reconnect to them, the operation either times out, it says the drives can't be found or that my LAN isn't running. I should note I'm using an AirPort Extreme base station to create my LAN and share my drives.
    To try to solve this, I have tried force quitting Finder, but then it won't start again, instead citing some error code.
    This again becomes a problem when trying to shut down as Finder is required to complete the process. The only way I can get around this is to force reboot my computer by holding the power button down until my MacBook shuts itself off.
    Immediately upon reboot, all programs that were affected by iTunes and RAM loss take an EXTREMELY long time to finish booting.
    All my software and drivers are up to date.
    I'm running OSX 10.6.8 on a late 2010 MacBook 2.4GHz Intel Duo core.
    AirPort is Extreme 2nd version running version 7.6.1
    ==Update==
    It seems two reboots are required for my drives to show up over my LAN.
    After the forced shutdown and reboot it doesnt work.

    I've gotten everything running again, but iTunes still persists in force booting itself when I don't ask it to.
    I've checked my sync and update settings on my iTouch, but it still does it.
    I've gotten past the Finder force reboot issues by just telling my computer to reboot when my network is experiencing difficulties.
    This has also solved the issue of said drives and network not showing up again upon reboot.
    Programs still take ages to boot if they were not quit properly (ie. iTunes caused massive lock up and programs had to be force quit), and this is still affecting my work flow negatively.

  • User and Group Issue

    Hello All,
    I am facing a issue in assigning users to groups in shared services. Version 11.1.1.3
    Actually users are present in LDAP and groups i created in Native Directory. Now i am writing Maxl .. Alter user ... add to group.... but its throwing a error that user doesnot exist, though the user exists in LDAP. I tried assigning users in groups manually, it worked. Can any one tell me how to do it through MAXL or any other way as i dont want to do it manually because there are 100s of user.
    2) Can any one please tell me the use of Updateuser and provisioning user utility. In what scenario we use them?
    Thanks,
    Abhi

    There is a way through Maxl an example being
    create or replace user 'essuser' type external;
    alter user 'essuser' add to group essgroup;
    or
    create or replace user 'essuser@LDAPNAME' type external;
    alter user 'essuser@LDAPNAME' add to group essgroup;
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Regex find and replace

    I have inherited a boatload of code that I need to "tweak".
    Currently, it contains many hundreds of refrences to a 2d
    array and
    references constants that I want to change to function calls.
    i.e.
    v(Svc,FutWTMargin)
    I want that to be changed into:
    v(Svc,getcol("FutWTMargin"))
    Now the bit in quotes "FutWTMargin" has many variations, but
    the structure
    of the original 2d array references are all consistent - it's
    just that
    there are several hundred of them that I need to change.
    Can someone help out with a regex that can change the
    FutWTMargin part to
    getcol("FutWTMargin") regardless of what the FutWTMargin text
    might actually
    say?
    Note to self... must learn regex at some point!
    Cheers,
    Rob
    http://robgt.com/ [Tutorials and
    Extensions]
    Firebox stuff:
    http://robgt.com/firebox
    Skype stuff:
    http://robgt.com/skype
    Dell stuff:
    http://robgt.com/dell
    SatNav stuff:
    http://robgt.com/satnav

    Thanks Mick!
    Cheers,
    Rob
    http://robgt.com/ [Tutorials and
    Extensions]
    Firebox stuff:
    http://robgt.com/firebox
    Skype stuff:
    http://robgt.com/skype
    Dell stuff:
    http://robgt.com/dell
    SatNav stuff:
    http://robgt.com/satnav

  • Sorting and grouping issue in WDP-ALV table

       lr_field->if_salv_wd_sort~create_sort_rule(
              EXPORTING
                sort_order        = if_salv_wd_c_sort=>sort_order_ascending
                group_aggregation = abap_true ).
    And while binding data, I'm sorting the internal table having data as below
    SORT wd_assist->gt_details_table(itab) BY bproc bsubproc function field ASCENDING.And output is as follows
    In the above snapshot, The sorting is getting disturbed on colunm: Function......
    But required output should be as below
    Pls help me how to achieve this?
    Thanks
    Katrice

    Hi Sandesh,
    When we use the SALV_WD_TABLE component to display ALV, by default, all columns are arranged in the same order as the attributes in the context node of your
    application.
    You need to add the following code in the wddomodifyview( ) method of your View.
    METHOD wddomodifyview
    data:lt_columns type salv_wd_t_column_ref,
            ls_column  type salv_wd_s_column_ref,
            lo_column  type ref to cl_salv_wd_column ,
            lo_ref_cmp_usage  type ref to if_wd_component_usage,
           lo_ref_interfacecontroller type ref to iwci_salv_wd_table ,
           lo_value type ref to cl_salv_wd_config_table.
    * Get  reference to the Component usage of the ALV.
    lo_ref_cmp_usage = wd_this->wd_cpuse_alv( ).
    IF lo_ref_cmp_usage->has_active_component( ) IS INITIAL.
    lo_ref_cmp_usage->create_component( ).
    ENDIF.
    * Get reference to the Interface controller of the ALV.
    lo_ref_interfacecontroller= wd_this->wd_cpifc_alv( ).
    lo_value = lo_ref_interfacecontroller->get_model( ).
    * Get the Columns of the ALV
    CALL METHOD lo_value->if_salv_wd_column_settings~get_columns
      RECEIVING
    value = lt_columns.
    * Get reference to each column and set the column position
    LOOP AT lt_columns INTO ls_column.
    lo_column = ls_column-r_column.
    CASE ls_column-id.
    WHEN 'VBELN'.
    lo_column->set_position('1').
    WHEN 'MATKL'.
    lo_column->set_position('2').
    WHEN 'POSNR'.
    lo_column->set_position('3').
    WHEN 'MATNR'.
    lo_column->set_position('4').
    ENDCASE.
    ENDLOOP.
    ENDMETHOD.
    Hope this helps you to resolve your issue.
    Thanks
    KH

  • Windows 7 DNS and Group Policy Issues

    Hi,
    We have several suites of Windows 7 domain connected PC's.
    In one of the suites I have been called into look at 3 different PC's where the users have not got mapped drives, desktop backgrounds, internet connectivity - because their group policies have not applied.
    When I look at the error logs I find DNS 1014 errors, and Group Policy 1054 errors.
    I have looked at the logs on the switches, and there is nothing on them - Could a pupil pulling the network cable out cause these errors?... Possibly they could have put it back in before I got back in the room.
    The user logs off of the PC and back on again and are fine, as are the users that logon after them.
    We have 2 DC's/DNS servers, which I would have thought would be able to cope with the load here.
    Please let me know what you think the likely cause could be.

    Hello John555444,
    What is your current situation?
    Is this issue resolved?
    Best regards,
    Fangzhou CHEN
    Fangzhou CHEN
    TechNet Community Support

  • Snow Leopard Finder's Get Info fails to show Owner and Group for some files or folders which reside on a Shared Volume, hosted by G5 Server w/ OS 10.4 - why?

    Frustrations with file permissions abound, as certain co workers are unable to manually determine their level of permission or who to ask to make changes to files and folders belonging to others. Users of Snow Leopard desktop OS get unhelpful feedback via Finder's Get Info, seeing only the permissions listed for "Everyone" and a statement that "You have custom access".  The custom message exists, presumably, because ACL's are employed on the shared volume in an attempt to give managerial control over these volumes to specific users, even if all users can create files and folders on those volumes.
    Shared volumes are partitions of an external RAID which are set up as sharepoints on a G5 tower running Server 10.4.  Other persons in the office, using machines that are running desktop OS 10.5, can correctly see the assigned Owner and Group permissions (although the "custom access" still shows).  This at least lets the 10.5 user know who created a given file or folder, so that they can resolve permissions-restricted issues if they come up (i.e. User A wants to delete file X, but as it was created by User B, A must contact B and have them delete it.  In 10.6 it appears that A cannot determine who B is).
    I know that ACL's are functioning (enabled on the drive) since we have been making use of ACL-granted write privileges for quite a while (and the custom access seems to be evidence too).
    An error I encountered, pertaining to this, is that I used a 10.6 machine to create a working folder, then generated and saved several files in this location.  Expected permissions thus would be Owner = me (i.e. the user I was logged in as), R/W, Group = staff, R only, Everyone = R only.  However, immediately the permissions shown in Finder / Get Info consisted only of Everyone = R only, with no entry for Owner or Group.  Moreover, clicking + to add either an Owner or a Group resulted in error message that I had entered an invalid user or group, even though I typed in correct info (such as trying to add "staff" as a group).

    Frustrations with file permissions abound, as certain co workers are unable to manually determine their level of permission or who to ask to make changes to files and folders belonging to others. Users of Snow Leopard desktop OS get unhelpful feedback via Finder's Get Info, seeing only the permissions listed for "Everyone" and a statement that "You have custom access".  The custom message exists, presumably, because ACL's are employed on the shared volume in an attempt to give managerial control over these volumes to specific users, even if all users can create files and folders on those volumes.
    Shared volumes are partitions of an external RAID which are set up as sharepoints on a G5 tower running Server 10.4.  Other persons in the office, using machines that are running desktop OS 10.5, can correctly see the assigned Owner and Group permissions (although the "custom access" still shows).  This at least lets the 10.5 user know who created a given file or folder, so that they can resolve permissions-restricted issues if they come up (i.e. User A wants to delete file X, but as it was created by User B, A must contact B and have them delete it.  In 10.6 it appears that A cannot determine who B is).
    I know that ACL's are functioning (enabled on the drive) since we have been making use of ACL-granted write privileges for quite a while (and the custom access seems to be evidence too).
    An error I encountered, pertaining to this, is that I used a 10.6 machine to create a working folder, then generated and saved several files in this location.  Expected permissions thus would be Owner = me (i.e. the user I was logged in as), R/W, Group = staff, R only, Everyone = R only.  However, immediately the permissions shown in Finder / Get Info consisted only of Everyone = R only, with no entry for Owner or Group.  Moreover, clicking + to add either an Owner or a Group resulted in error message that I had entered an invalid user or group, even though I typed in correct info (such as trying to add "staff" as a group).

  • MAJOR Open Directory issue: Can't assign Users and Groups that DO exist!

    Just noticed the following today:
    When doing Get Info -> Permsissions on files/folders located on my File Server share, Owner and Group show as (unknown).
    When I go into WGM -> Sharing, and look at files/folders on File Server share this way, the Owner and Group fields are blank.
    When I attempt to (re)assign an Owner or Group by dragging them from Users and Groups section of WGM, error tells me User or Group no longer exists. These Users and Groups clearly do exist in WGM -> Accounts.
    When I look at files on File Server share via CLI, instead of actual names for Users and Groups, I see their uid and gid's. Chowning via CLI fails as well.
    I've noticed all Users and Groups with this issue are OD.
    Server is xServe G4 DP 1.0 GNz/1 GB RAM/Mac OS X Server 10.4.7 Unlimited. This servers been running fine as an OD Master for months now. ACL's are enabled on this File Server share point. I've always had weird permissions issues, but NEVER the inability to assign OD Users and Groups to files/folders.
    I'm at a loss here, not to mention my wits end.
    Did my OD become corrupted?
    Any and all help would greatly appreciated.
    PowerMac G4 733 MHz   Mac OS X (10.4.6)   512 MB RAM

    When doing Get Info -> Permsissions on files/folders located on my File Server share, Owner and Group show as (unknown).
    This means that the Finder can't find a match in the accounts/groups database for the numeric UID assigned to those files. Either the records associated to those accounts have been deleted, or the database is corrupt. In either case, you should restore a copy of it from backup.
    (15686)

  • Hi frnds, I just purchased Ip4 and upgraded to ios 7 but it become slow and i cant find any group sms option.

    Hi frnds, I just purchased Ip4 and upgraded to ios 7 but it become slow and i cant find any group sms option.

    Thanks so much for your reply, yes I did and that has not worked either . A friend has suggested re installing upgrade, so may try that .

  • I want to delete a group on my iChat list, but it doesn't go away when I right click and delete it. No ones in the group and I tried the plus button on the bottom left of the list and I can't find "edit groups"

    I want to delete a group on my iChat list, but it doesn't go away when I right click and delete it. No ones in the group and I tried the plus button on the bottom left of the list and I can't find "edit groups"

    WordPress is in a class of it's own.  It began it's open source life as a blogging system but it has evolved into a powerful, feature-rich CMS (content management system).  In short, if you elect to use WordPress on your domain, you might just as well use it for your entire web site.
    To work with WordPress, you will need a firm understanding of HTML, CSS and how PHP includes work.
    WP requires you to set-up a dynamic work environment (see links below)
    Find a WP Theme you like that won't require much customizing on your part.
    Related Links:
    http://wordpress.org/
    Get one of the following testing servers for your OS and follow the installation instructions.
    WAMP for Windows
    http://www.wampserver.com/en/
    XAMPP for Windows
    http://www.apachefriends.org/en/xampp-windows.html
    XAMPP for Mac
    http://www.apachefriends.org/en/xampp-macosx.html
    MAMP for Mac
    http://www.mamp.info/en/downloads/index.html
    Setting up a PHP development environment for Dreamweaver
    http://www.adobe.com/devnet/dreamweaver/articles/setting_up_php_05.html
    Creating a WordPress Theme in DW
    http://www.adobe.com/devnet/dreamweaver/articles/creating_wordpress_theme_with_dreamweaver _pt1.html
    Best of luck,
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    http://alt-web.com/
    http://twitter.com/altweb
    http://alt-web-design.blogspot.com/

  • Help with find and replace regex

    Hello.
    I have a page listing about 50 services that have named
    anchors to a
    glossary page. Something like this:
    <a href="/glossary.html#Blogging">Blogging</a>
    And what I need is to have the glossary open in a new window.
    So how
    do I write a regex that will give me:
    <a href="/glossary.html#Blogging"
    taget="blank">Blogging</a>
    Thanks for any help
    Lance

    Thanks Brendon.
    It's Regular Expression; an optioin in the find and replace
    dialog.
    I've got to replace 50 of these anchors, each different.
    <a href="/glossary.html#Blogging">Blogging</a>
    <a href="/glossary.html#yadayada">yadayada</a>
    etc.
    to make them each open in a new window.
    <a href="/glossary.html#Blogging"
    taget="blank">Blogging</a>
    L.
    On Thu, 18 Oct 2007 14:40:46 +1300, "Brendon"
    <[email protected]>
    wrote:
    >Whats a regex?
    >Why not just do a Find and Replace? Specify the current
    local site, and
    >voila. Make sure you spell target correctly though ;-)
    >
    >
    ><@networkologist@@gmail.com> wrote in message
    >news:[email protected]..
    >> Hello.
    >>
    >> I have a page listing about 50 services that have
    named anchors to a
    >> glossary page. Something like this:
    >>
    >> <a
    href="/glossary.html#Blogging">Blogging</a>
    >>
    >> And what I need is to have the glossary open in a
    new window. So how
    >> do I write a regex that will give me:
    >>
    >> <a href="/glossary.html#Blogging"
    taget="blank">Blogging</a>
    >>
    >> Thanks for any help
    >>
    >>
    >>
    >> Lance
    >

  • Okay, for a novice (iphone for dummies) what steps to take and in what order to identify specific problem and resolve issue of dropped calls and/or bad connections.  I have a 3g iphone4, I think.  Where is best place to find that information so I can veri

    Okay, for a novice (iphone for dummies) what steps to take and in what order to identify specific problem and resolve issue of dropped calls and/or bad connections.  I have a 3g iphone4, I think.  Where is best place to find that information so I can verify.  

    You can call your wireless provider and talk to them about it.
    You can restart your iphone, reset, your iphone and restore your iphone.

  • Extremely difficult to toggle switches on and off in settings in iOS6, on multiple devices, iP5, 4S, 4 and new iPad. Are others finding the same issue?

    Extremely difficult now to toggle switches on and off in settings in iOS6, on multiple devices, iP5, 4S, 4 and new iPad. Are others finding the same issue?

    I solved this by reset of the Wifi (unplug cable and power to both modem and wifi ... wait 60 sec ... plug in modem cable and power ... plug in wifi power and LAN to modem ... restart AppleTV and Mac ... Turn Home Share 'OFF' in iTunes then back "ON" ... it took ~60 sec for the AppleTV to pick up my Mac in computers.

Maybe you are looking for