Tricky regex problem

OK it's late but this one has me stumped. I need to
dynamically change URLs in a block of HTML. Sounds easy, except
what if the URL is something like "/index.cfm" that I want to
change to, say, "/newdir/index.cfm".
In other words, I'd want all these to match:
/index.cfm
http://www.site.com/index.cfm?name=value
ftp://www.anothersite.com/index.cfm
But definitely NOT anything that's a different URL, like:
/subdir/index.cfm
Basically, I don't want a situation where /subdir/index.cfm
is translated into /subdir/newdir/index.cfm
To that end, I figured I'd take any match for my directory,
EXCEPT where it was immediately preceded by some other subdirectory
. However, the only way I can think of to do this is with an
intermediary value, as in:
HTMLString = 'a href="/leavethisalone/index.cfm" a
href="/index.cfm?name1=var1"';
HTMLString = REReplaceNoCase(HTMLString,
"(\/[0-9a-zA-Z\-]+)\/index.cfm", "\1SomethingThatIsNeverInHTML",
"ALL");
HTMLString = replaceNoCase(HTMLString, "\/index.cfm",
"/newDirectory/index.cfm", "ALL");
HTMLString = replaceNoCase(HTMLString,
"SomethingThatIsNeverInHTML", "/index.cfm", "ALL");
This gets expensive as I'm doing two extra replaces. Is there
a way to just do this in one go?
Thanks,
- Andrew.

Your problem can get tricky but as you've described it, this
should work:
REReplaceNoCase (" " & HTMLString, "(
http://[0-9a-z_\.-
"\1/newdir/index.cfm", "ALL");

Similar Messages

  • Tricky syncing problem

    I have a tricky little problem I hope someone can help me resolve. I have an iPhone and a registered Apple account. My son have also an iPhone and have used my account to purchase apps and music, which is perfectly in order since he have my permission and was a little too young to have an own credit card. He have never synced his iPhone with iTunes, only downloaded the apps and songs from App store directly on the phone. But now he is going to get his own credit card to use with his own Apple account, and of course he wants to keep, his music, photos, videos and the apps he have downloaded and purchased (and I have paid for =)
    I'm not really sure how to make this happen so any help is appreciated.
    He have inherited my old iMac that I have recently made a clean install of Mavericks on, and I have a new Macbook that I haven't yet synced my iPhone with, but I copied my old iTunes folder to an external USB drive and is planning to replace the empty iTunes folder on my new Macbook. The apps and music my son have purchased with my account is installed on his iPhone only.
    Don't know if this is even resolvable, but thought I give it a go here to see what you clever people can come up with.

    Unfortunately, apps are not transferrable between iTunes accounts, which means he won't be able to keep those apps.  It doesn't matter if he uses an old computer of yours, once he logs into the iTunes store with his ID and syncs his iPhone the apps may be removed (and if not, he'll have to enter your password each time there's an update to those apps, which may not be what you'd want).
    Music can be shared between accounts.  If you are passing on your iMac, but have erased the iTunes library in the process of installing Mavericks, he can still re-download the songs from iTunes as long as he's logged into your account in iTunes (click the "Purchased" link in the store).  Once he re-downloads the songs he wants, he can log out of the iTunes account and log in with his, and the music will remain playable and can sync to his iPhone.  Future purchases would go against his account.  While logged into your account, resist the temptation to re-download apps since once he logs out of your account and into his, those apps will prompt him for your password on each update.
    Alternative to re-downloading songs to the computer, if he first signs into iTunes with your account and connects his iPhone, he should be prompted to transfer all purchased content, including apps.  Once the transfer to the iMac is complete, then sign out of iTunes and sign back in with his new ID.  But again, delete the apps purchased on your account to avoid problems.
    One warning though, once he syncs the iPhone with the iMac it may prompt him to erase it.  But if it has never been synced with any computer, maybe not.  If it is, at least he'll have the music in the iMac's library to re-add to the iPhone.  But to save photos and settings, etc. it may be best to backup the iPhone to iCloud first.

  • RegEx Problem with flag COMMENTS

    Hello,
    I have the following Exception:
    java.util.regex.PatternSyntaxException: Unclosed group near index 9
    when my program is running with this flags:
    Pattern patt = Pattern.compile("^(@#@.+)$", Pattern.MULTILINE | Pattern.COMMENTS);but when I run this:
    Pattern patt = Pattern.compile("^(@#@.+)$", Pattern.MULTILINE);it works fine.
    Any COMMENTS ;-) for this problem? The entire RegEx is much bigger. I want to comment it.
    Thanks sacrofano

    Hi,
    thanks for your help, but it did not work.I did not suggest anything that would work! I was trying to point out that the Javadoc says that everything from # to the end of the pattern is treated as comment.
    I run this
    Pattern patt =
    Pattern.compile("^(?:(@#@.+))$",(Pattern.COMMENTS));[/
    code]So why, based on reading the Javadoc, would you expect this RE to compile? Everything after the # is treated as comment so your effective regular expression is "^(?:(@" which is obviously an invalid RE!
    with same exception as above.
    Is there a problem with the Flag Pattern.COMMENTSNo! RTFD.

  • Tricky design problem

    The system I'm working with stores travel paths. The tricky thing is that these travel paths must be unique.
    Path, [Locations]
    1, [A, B, C]
    2, [A, C]
    3, [C, A]
    4, [A, B, C, D]
    Note that path 2 and 3 are fine since the order of the locations has changed.
    Since the number of places a path can include is relatively small, I thought I could create a compound unique secondary key for each path consisting of the UID of each place in the correct order (in the correct order and separated by a hyphen). To bind a path to Locations and vs. I'd add an associative PathLocations Table (including sequence information) and implement an insert/update/delete trigger that would modify the associated Path's compound key. This would fail if the unique constraint was violated.
    Mechanically this will no doubt work, but it feels so ugly I wonder if anybody had an elegant solution for this problem.
    Thanks for any ideas and pointers in advance.
    Pete
    Edited by: petehug on Mar 11, 2012 3:10 PM
    Edited by: petehug on Mar 11, 2012 3:11 PM

    In the year 2042, when we might finally have got support for the CREATE ASSERTION statement, we could implement your requirement with the following 'patterns':
    create table points -- Aka. locations
    (id     number not null primary key
    ,c1     varchar2(10) not null)
    create table lines -- Aka. paths
    (id     number not null primary key
    ,c1     varchar2(10) not null)
    create table line_vertices -- Pathlocation
    (line     number not null
    ,from     number not null
    ,to     number not null
    ,check(from != to)
    ,unique(line,from)  -- prevents splits
    ,unique(line,to)    -- prevents merges
    ,foreign key (line) references lines
    ,foreign key (from) references points
    ,foreign key (to) references points)
    Rem
    Rem Prevents disjunct line-segments within a line (route).
    Rem Also prevents 'loops'.
    Rem
    create assertion one_origin_per_line as
    check(not exists
            (select 'a line without exactly one origin'
               from lines l
              where 1 != (select count(*)
                            from line_vertices v1
                           where v1.line = l.id
                             and not exists
                                   (select 'a previous hop'
                                      from line_vertices v2
                                     where v2.line = l.id
                                       and v2.to = v1.from)))
    Rem
    Rem Redundant, but mentioned for clarity.
    Rem
    create assertion one_destination_per_line as
    check(not exists
            (select 'a line without exactly one destination'
               from lines l
              where 1 != (select count(*)
                            from line_vertices v1
                           where v1.line = l.id
                             and not exists
                                   (select 'a next hop'
                                      from line_vertices v2
                                     where v2.line = l.id
                                       and v2.from = v1.to)))
    Rem
    Rem All lines must be 'unique'.
    Rem
    create assertion no_duplicate_lines as
    check(not exists
            (select 'two lines with same vertices'
               from lines l1
                   ,lines l2
              where l1.id !=l2.id
                and not exists
                      (select 'a l1-vertice not in l2'
                         from line_vertices v1
                        where v1.line = l1.id
                          and not exists
                                (select 'a matching vertice in l2'
                                   from line_vertices v2
                                  where v2.line = l2.id
                                    and (l2.from,l2.to) = (l1.from,l1.to)))
                and not exists
                      (select 'a l2-vertice not in l1'
                         from line_vertices v2
                        where v2.line = l2.id
                          and not exists
                                (select 'a matching vertice in l1'
                                   from line_vertices v1
                                  where v1.line = l1.id
                                    and (l1.from,l1.to) = (l2.from,l2.to)))
    /Edited by: Toon Koppelaars on Mar 16, 2012 11:16 AM

  • Phone field regex problem

    Hi, I need a little help with my regex... it works good, except for one last issue.
    /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4} ?)$/
    I have a single phone field. And  it to allows just 10 digits, or digits with dashes, or digits with parenthesis, or digits with spaces. And it even allows the user to insert a white space at the end (by accident).  This all works good.
    But I was told that no area codes in the US start with a 0 or 1?  How can I make it only have a range of 2 to 9 for the area code?
    I tried to use [2-9] but this doesn't work.
    Thanks in advance!

    The problem is that you are trying to match three digits with a [2-9] range, not just the first number.
    for example:
    333-444-555 will match because all three of the first section of digits are between 2 and 9,
    211-222-333 will not work, because 1, is the second number and you are only looking for 2-9.
    does this make sense? you have the three first numbers group together in one rule
    -Julia

  • Small RegEx problem

    Hello fellow Programmers!
    I turn to you because this small regular expression is turning me NUTS! AHHH!
    My String:
    blalba[morebla]evenmorebla]blaMy RegEx:
    \[.*(\]){1}My Aim:
    To get the first Bracket and everything between and inculding the second bracket. So that would be:
    "[morebla]"
    The Problem is I get the first bracket and everything until the LAST bracket.
    "[morebla]evenmorebla]"
    I assume this is so because ".*" just runs over everything until a final bracket appears...
    Any thoughts?

    anox wrote:
    Smithberrys suggestion worked.
    The other one didn't work out with my regEx but I am currently looking into that question mark and its functions.
    Thanks guys!Didn't work? How did you use it? Where did you use it?
    public class RegexpSample {
        public static void main(String[] args) {
            String data = "blalba[morebla]evenmorebla]bla";
            Matcher matcher = Pattern.compile("\\[.*?\\]").matcher(data);
            matcher.find();
            System.out.println(matcher.group());
    }Prints:
    [morebla]
    * is normally greedy, and a question mark makes it reluctant.
    You can find more info in the javadoc for the Pattern class, and on www.regular-expressions.info
    Kaj

  • Tricky regex, splitting at singular capital leter

    Hi folks, could you help me with this:
    I want to be able to split the following works in at the capital letters:
    UserArea
    User Area
    userArea
    User Area
    UserAREA
    User Area
    sserAREA
    User Area
    note arbitary amount of joined words
    I had a look at this page but their solution doesn't cover all my needs
    http://www.webhostingtalk.com/showthread.php?t=527597
    I've used regex before but nothing this tricky, appreciate any advice you can share with me

    I recently did a search for some regex stuff. After I read the adobe docs, I happened to come across some site showing features that are actually part of ecmascript standard. So this encouraged me to just try things I know from another environment and see whether flash happens to understand them
    Of course, a simple test script where you can input both regex and test data is likely to save a lot of time

  • Z77A - GD65 - tricky one problem with 1X and 16x mix.

    I can tell you some feedback that I have done extensive testing on - ANY help would be greatly Appreaciated !
    (if you have a digital wallet of particular happy to send Crypt cunnency ! for solution ! )
    I have 6 7900 Series ATI for sCrypt mining  using CGminer  but all that aside i think this is a PCie problem?
    on our MSI Z77a_GD65 - if a 1X and a 16X slot are connected the  16X slot get allocated GPU 0 in CGminer and by default sets to 500MHz Core and 150Mhz mem clock. i.e it does not function properly -
    its like the plugging in of a card to the 1X slot is voltage down the 16X pcie slot - or taking Channel space from it?
    This board has 6 usable slots - if 3 Cards are in 3 1X slots then all will # at around 550 500 K# without tweaking no problems , everything is normal .
    likewise if 3 Cards are in 16X size slots - all cards Run  , 3 cards run  fine .
    BUT
    if slots are mixed - even just 2 cards  i.e 1 Card on a 1X and 1 Card on a 16X  - then CGminer sets GPU 0 to the the card present in the 16X slot and sets it to 500mhz Core and 150Mhz memclock .
    I've tested multiple combinations of 1X and 16X slots so as to exclude any particular slot  i.e 1 and say 5 and 3 and 2 .
    Also updated Bios to 10.8 which states "better Pcie Compatibility"
    Set PCIe Latency to 96 in Bios.
    danced around room with wooden totum , sacraficed a rubber chicken.
    Disabled Gen3 becasue it is not needed - Cyrpt mining does not need bandwith.
    looking for the answer, maybe a voltage issue?
    may result in jumper or Pin?
    power is ample have 1500W Revo _ and this happens when running just 2 cards.
    8 Gig Ram - Processor INTEL G1610 - should have enough PCI channels ?
    Driver 13.5 - SDK 2.6 - not a Driver problem tried nearly all drivers.
    PCIe Problem !? voltage issue?
    ** also any card run singally by itself in any single 1X or 16X slot is fine and performs normally.
    I purcahsed the Motherboard New and it still has Warranty.  (other than that love the booard, love the onboard IO button)

     The Intel X79 Express platform supports 40 PCIe 3.0 lanes via the CPU for graphics. The Intel X79 Express PCH itself supports eight lanes of PCIe 2.0 connectivity for other external devices.
     Of that would also require purchase of Sandy-E CPU along with the BB-XP ll
     Compare that with the much less 16 lanes for Sandy & Ivy platforms.
     It's not an issue of how many cards you use, it's how many lanes each card uses. If you use 3 cards that use up all lanes and have empty slots they are useless anyway because you have already used up all available lanes.

  • Mod_Rewrite/Restart Regex Problem

    I'm trying to migrate to SJWS 7.0R1 from Apache, and trying to migrate the following rewrite functionality:
    Rewriterule ^(.*/)$ asp.php?url=$1index
    Rewriterule ^$ asp.php?url=index
    Rewriterule ^admin(/+(.*))?$ admin.php?url=$2
    RewriteCond %{REQUEST_FILENAME} !-f
    Rewriterule ^(.+)\.asp$ asp.php?url=$1&%{QUERY_STRING}
    RewriteCond %{REQUEST_FILENAME} !-f
    Rewriterule ^([^\.]+)$ asp.php?url=$1
    RewriteCond %{REQUEST_FILENAME} !-f
    Rewriterule ^(.+)$ file.php?url=$1
    I've successfully started with redirecting the base to asp.php?url=index, but beyond that, I'm getting errors related to either the backreference not being picked up, or being undefined. The URL I'm working with at the moment is:
    (From the Virtual Server's obj.conf file)
    <Object name="default">
    NameTrans fn="restart" from="/" uri="/asp.php?url=index" (This Works)
    This directive (See Error #1)
    <If $uri =~ "^/([a-z].*)">
    NameTrans fn="restart" uri="/file1.php?q=$1"
    </If>
    or, this directive (See Error #2)
    <If $uri =~ "^/([a-z].*)">
    NameTrans fn="restart" from="^/([a-z].*)" uri="/file1.php?q=$1"
    </If>
    The errors that I'm getting:
    Original URL: /sun_components/index.asp
    Error #1:
    failure (24219): trying to GET /file1.php whiletrying to GET /asp.php while trying to GET /, HTTP2297: Cannot restart request for /file1.php?q=file1.php (Exceeded maximum of 50 restarts)
    (Notice that the backreference doesn't get picked up, and is instead referencing file1.php)
    Error #2:
    failure (24219): for host XXXXX trying to GET /sun_components/index.asp, handle-processed reports: TTP2298: Error interpolating parameters for restart (Backreference $1 undefined)
    Thanks very much in advance for any help you can give me.
    -Doug

    OK, I had used the $restarted check, and that's all working great. However, on a separate VirtualServer, I'm having the following problem: when I include the $restarted check, it returns a 404 error; when I remove it, it ends up in an infinite loop. If I manually put in the rewritten url, all works fine. Logs are below, which show that it restarts, but after it restarts, it continues trying to process on the original URI, rather than on the restarted one.
    [12/Dec/2007:11:19:15] finest ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/index.php, =~ reports: Subject "/new_hampshire/docs/990_party_stores/index.php" matches pattern "^/new_hampshire/docs(.*)$" with 1 capturing subpattern(s)
    [12/Dec/2007:11:19:15] finest ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/index.php, func_exec reports: executing fn="restart" uri="docs.php?url=/990_party_stores/index.php" Directive="NameTrans"
    [12/Dec/2007:11:19:15] fine ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/index.php, restarting request as docs.php?url=/990_party_stores/index.php
    [12/Dec/2007:11:19:15] finest ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/docs.php while trying to GET /new_hampshire/docs/990_party_stores/index.php, func_exec reports: fn="restart" uri="docs.php?url=/990_party_stores/index.php" Directive="NameTrans" returned -4 (REQ_RESTART)
    [12/Dec/2007:11:19:15] finest ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/docs.php while trying to GET /new_hampshire/docs/990_party_stores/index.php, process-uri-objects reports: processing objects for URI /new_hampshire/docs/990_party_stores/docs.php
    [12/Dec/2007:11:19:15] finest ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/docs.php while trying to GET /new_hampshire/docs/990_party_stores/index.php, process-uri-objects reports: adding object name="default"
    [12/Dec/2007:11:19:15] finest ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/docs.php while trying to GET /new_hampshire/docs/990_party_stores/index.php, func_exec reports: executing fn="match-browser" browser="*MSIE*" ssl-unclean-shutdown="true" Directive="AuthTrans" magnus-internal="1"
    [12/Dec/2007:11:19:15] finest ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/docs.php while trying to GET /new_hampshire/docs/990_party_stores/index.php, func_exec reports: fn="match-browser" browser="*MSIE*" ssl-unclean-shutdown="true" Directive="AuthTrans" magnus-internal="1" returned -2 (REQ_NOACTION)
    [12/Dec/2007:11:19:15] finest ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/docs.php while trying to GET /new_hampshire/docs/990_party_stores/index.php, func_exec reports: executing fn="ntrans-j2ee" name="j2ee" Directive="NameTrans"
    [12/Dec/2007:11:19:15] finest ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/docs.php while trying to GET /new_hampshire/docs/990_party_stores/index.php, func_exec reports: fn="ntrans-j2ee" name="j2ee" Directive="NameTrans" returned -2 (REQ_NOACTION)
    [12/Dec/2007:11:19:15] finest ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/docs.php while trying to GET /new_hampshire/docs/990_party_stores/index.php, func_exec reports: executing fn="pfx2dir" from="/mc-icons" dir="/sun/webserver7/lib/icons" name="es-internal" Directive="NameTrans"
    [12/Dec/2007:11:19:15] finest ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/docs.php while trying to GET /new_hampshire/docs/990_party_stores/index.php, func_exec reports: fn="pfx2dir" from="/mc-icons" dir="/sun/webserver7/lib/icons" name="es-internal" Directive="NameTrans" returned -2 (REQ_NOACTION)
    [12/Dec/2007:11:19:15] finest ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/docs.php while trying to GET /new_hampshire/docs/990_party_stores/index.php, func_exec reports: executing fn="check-acl" acl="default" Directive="PathCheck"
    [12/Dec/2007:11:19:15] finest ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/docs.php while trying to GET /new_hampshire/docs/990_party_stores/index.php, func_exec reports: fn="check-acl" acl="default" Directive="PathCheck" returned -2 (REQ_NOACTION)

  • Tricky File Problem!!

    I have written an Internet application that uploads
    desired image-files to the server. After the image
    has been uploaded I try to read it and scale it using:
    Image inImage = new ImageIcon(imageFilename).getImage();The problem is that the image won't be read!!! I think
    this has to do with permissions on the server, am I right???
    Because when the file is upload the permissions har set to:
    -rw-r--r--    1 nobody    nogroup   1460217 aug 9 23:19 theImage.jpgI should add that the server is a Linux-server and the directory is
    something like:
    /home/a/acompany/upload/The directory has these permissions:
    drwxrwxrwx    2 oknjudun users         248 aug  9 23:36 upload/Why doesn't it work to read the image????
    Please help, Ernstad

    have you tried doing this:
    chmod a+rwx <insert file name>
    on the file to see if that makes a difference (i.e. works).. thus confirming your theory?
    Tim

  • Tricky bridge problem to studio out back in the woods.

    I've tried all sorts of configurations... here is the problem: Happy in the house with my MacBook and my husband's iMac using airport to the old clam- shaped Extreme and DSL. Would like to use my old iBook for internet work out at my studio space that is out back - 160 yds into the woods. My husband's office is about half way between so I thought if I could bridge the airport stations, I might get this to work.
    I purchased Airport Extreme and an Airport Express to use for the bridge. Is it too far for the signal, as all I get is the flashing amber signal? Do I need to load more software? I don't want to screw up the existing network, so I'm reluctant to try this. I'm stumped and the stuff is due back in Rochester (hour and a half away from here) in a week if it doesn't work. Any geniuses out there that could help with some advice? Thanks!

    mharris56, Welcome to the discussion area!
    The range of the AirPort Express (AX) is 50 yards. So it won't bridge the link from your house to your husband's office nor the link from your husband's office to your studio.

  • Java regex problem

    Hi:
    I have the following texts in a flat file:
    scheduler is running
    system default destination: llp
    device for ps3: /dev/ps3
    device for ps: /dev/ecpp0
    device for llp: /dev/ecpp0
    How can I use java regex to print out the string after "device for " in this case the string "ps3" ,"ps" and "llp".

        static final Pattern DEVICE_PATTERN = Pattern.compile(
                                          "device for ([^:]++)" );
        String text = "";
        Matcher m = DEVICE_PATTERN.matcher( text );
        while ( (text = bufferedReader.readLine()) != null ) {
            if ( m.reset(text).lookingAt() ) {
                String device = m.group( 1 );
        }

  • SQL statement - tricky search problem

    Hi,
    I am working in asp and use an Access db. I have a database
    with 500 shops around the world, the table contains among other
    things shop name, country and region (Europe, Asia etc). Then a
    search page with dropdown lists, one for Region and one for
    Country. Here is the problem, which seems easy first, but I really
    can´t get the sql statement to do what I want:
    The Region list has the following values:
    Any region
    Europe
    Asia
    etc
    The country list has te following values:
    Any country
    Sweden
    Germany
    USA
    etc
    Ok, so the problem is if the user choose "Any Region" and
    "Any Country" all shops should come up. "Europe" and "Any Country"
    should give all shops in Europe". "Any region" and "Sweden" should
    pull up ONLY shops in Sweden. "Europe" and "Sweden" should also
    pull up shops in Sweden only.
    Now you start see the problem. I have laborated with AND resp
    OR statments and also % resp xyz in the "Any Country" and "Any
    Region" values.
    Any help would be highly appreciated! Thanks!!

    Thank Manish,
    Could you tell me how to restrict in following codes?
    select
    e.EQUIPMENT_ID,
    e.HOST_NAME,
    e.SERIAL_NUMBER,
    e.CITY,
    e.ROOM,
    e.RACK,
    e.CR_DT,
    e.CR_USR,
    e.LM_USR,
    e.LM_DT,
    e.TASK_TASK_ID
    from SVR_EQUIPMENT e
    where
    instr(upper(e.SERIAL_NUMBER),upper(nvl(:P1_REPORT_SEARCH,e.SERIAL_NUMBER))) > 0 and
    instr(upper(e.CITY),upper(nvl(:P1_REPORT_SEARCH,e.CITY))) > 0 and
    instr(upper(e.CR_USR),upper(nvl(:P1_REPORT_SEARCH,e.CR_USR))) > 0 or
    instr(upper(e.LM_USR),upper(nvl(:P1_REPORT_SEARCH,e.LM_USR))) > 0
    Thanks for all again,
    Sam

  • Regex problem: return all solutions

    Hi all,
    I would like to force backtracking on a regular expression, in order to return ALL POSSIBLE SOLUTIONS. For example, the regex:
    (a*(b))
    applied on "aaaab" on the group0 returns:
    "aaaab"
    I would like it to return:
    "aaaab"
    "aaab"
    "aab"
    "ab"
    "b"
    that is, all solution for group0.
    Do you know how to do it? As far as I know, using the Matcher.group(int) method it only return the LAST finding of the group (in my case "aaaab", or "ab" if you use lazy).
    Thank!
    Legolas

    Yes, I though about this solution, but it seems to me a little "dirty" and inefficient...
    It seems me so strange that they didn't try to implement class method that does backtracking !! (to emulate a declarative language, eg Prolog)
    Anyway, thaks a lot...it seems the only possibile solution to force explicitely the backtrack.
    Legolas

  • Simple regex problem

    In the application that I'm working on, input is validated while the user is typing, i.e. an entire text field is validated every time that a new character is inserted. I'm trying to check for a valid decimal number using this regular expression. (I know that it will also be true for blank values, but parseDouble() should take care of that.) Can anyone see something wrong here? My textfield doesn't accept any input when validation takes place using this expression.
    //Decimal numbers
        public final static String DECIMALNUMERIC = "[0-9]*\\.*[0-9]*";

    sabre150 wrote:
    codingMonkey wrote:
    prometheuzz wrote:
    But a better approach would probably be to use a JFormattedTextField:
    [http://java.sun.com/docs/books/tutorial/uiswing/components/formattedtextfield.html]
    No can do. My company has a bunch of components that we've made specifically for the system that we're working on. That expressions looks a bit to big and complicated for something as simple as this, and I don't have to cater for negative values.
    Yet they allow you to use a piss poor regex to validate a number and they allow the abomination you propose in http://forum.java.sun.com/thread.jspa?threadID=5278584&messageID=10168724#10168724 . Wow!
    Why is that so terrible?

Maybe you are looking for

  • Problems / Bugs / Improvements we have found - Experienced users.

    Hello there, I work for an animation / film company and After Effects is an integral part of out production services. As much as we love the program, its not without its flaws. Here are some things we have found after using After Effects day in and d

  • 10.10.2 keeps trying to access disconnected server

    Hi there, kids! Something in my 10.10.2 setup insists on trying to access a server that no longer resides at a particular address.  Access to the new address is all good, but I keep getting interrupted by messages about the old one being offline/disc

  • Windows Server 2003 (sp2 - 32bit) - OEM problem

    I inherited this in-house (closed) system a few years ago and have not had a problem until a couple of months ago.  It has been running for about 1 1/2 years. Desc:   Oracle 11.1.0.6 (64bit) on Windows Server 2003 (sp2 - 32 bit)   [[ yes, I know, wha

  • I can not use trackpad zoom function in FF4

    i can not zoom in w FF4 by trackpad or magic mouse for osx 10.6.7

  • Using iphone with cingular

    I am a cingular user already and I do not need the iphone's internet everywhere feature. So I am wondering, since I will only use the internet when I have wifi, can I keep my original phone plan and use the iphone?