Seemingly simple, yet annoying reg. expression issue

Hey guys,
Im considerably familiar with the use of regular expressions in Java (and other languages), yet seem to be having a very simple problem.
I wish to match a full stop character occuring after a space in a string, once that space does not occur after a digit.
e.g. "went to the shop . This is another sentence"
The code I'm using is this:
String s = "went to the shop. This is another sentence"
s = s.replaceAll("([^0-9]+)\\s+\\.","$1.");This doesn't seem to work, neither does:
String s = "went to the shop. This is another sentence"
s = s.replaceAll("(\\D+)\\s+\\.","$1.");It seems that there's a problem with the first + symbol, but I'm not sure exactly what the problem is.
Any insights?
Edited by: SuperGrover on Jan 19, 2009 12:35 PM

SuperGrover wrote:
The problem seems to occur when there's more than one occurance of the space before a fullstop in the string, so the above code doesn't work for the following string:
"went to the shop . This is another sentence . And another"
It only replaces the final occurance, despite using the replaceAll method.When I tested your pattern (using JRET), it matched both occurrences in the sample string!
The matching was done by repeated invocations of the method [Matcher.find|http://java.sun.com/javase/6/docs/api/java/util/regex/Matcher.html#find()].
Maybe [String.replaceAll|http://java.sun.com/javase/6/docs/api/java/lang/String.html#replaceAll(java.lang.String, java.lang.String)] does something different internally?
Anyway, are you aware that your expression always matches the entire string preceding the space and the dot?
This is probably not really what you are looking for. You may want to try this expression instead, which uses negative lookbehind:
(?<!\d)\s+\.Edited by: McNepp on 20.01.2009 09:47

Similar Messages

  • LMS 4.0 Compliance Reg Expression Issue

    I'm
    having problems with a regexp, I'm trying to search for multiple patterns in the loopback description field:
    Example:
    Rtr1:
    interface loopback0
    description rndm:text:cursor:1536:blah:blah1
    Rtr2:
    interface loopback0
    description rndm:text:cursor:3072:blah:blah1
    The regular expression that works is:
    +interface Loopback0
    + [#description .*:.*:.*:1536:.*#]
    But that only searches for one instance, what I cannot get to work is the following:
    +interface Loopback0
    + [#description .*:.*:.*:1536|3072:.*#]
    I have tried many variants, but I cannot get the (pipe) to work properly.
    Thanks in advance for any help,
    Craig

    Nope, still no luck, I did have to add \ in front of the
    colons to get the specific location, the asteriks wwould allow it to search for that sting any
    where in the description, but I couldn't get the pipe to work properly still, I've trie
    d moving the hard brackets, paranthesis etc.
    I ended up working around the problem, by creating individual lines:
    +[#description .*\:.*\:.*\:1536\:.*\:.*\:.*#]
    +[#description .*\:.*\:.*\:3072\:.*\:.*\:.*#]
    +[#description .*\:.*\:.*\:2048\:.*\:.*\:.*#]
    Then running the report, the report gave the output of which commands needed to be "added", so I used a seperate program to determine which devices were non-compliant, IE.
    If router one needed all 3 of those commands, then I knew it did not match any of them, and was non-compliant, if router two only needed 2 of those commands, I knew that it was compliant.
    Kind of a backwards approach, and I would still like to see the search work.
    Thanks for the help,
    Craig

  • Annoying desktop wallpaper issues

    Lately i'm having issues with my wallpaper on my macbookpro. The state of my wallpaper now is white, just white nothing else. I try and apply a new image but it doesnt seem to do anything. Whenever i reboot my mbp, my old wallpaper images displays for a couple of seconds until osx is fully loaded but then goes back to white. I use a secondry monitor as well, but it displays images, just not the screen on my mbp. The mmp works perfecly, nothing else wrong with it (touch wood) just this really annoying desktop wallpaper issue!
    Anyone have any ideas?
    Thanks.

    Ok it seems to of been a wee app called instantshot that was the culprit.

  • Seemingly Simple

    Hello,
    I am trying to create a seemingly simple effect in Motion and having some trouble.
    I am trying to do a simple zoom out from a "fill screen" (text size fills screen) to a hault and then slow crawl (text fills screen, slams to a smaller size and then slowly crawls backward). This is pretty much a standard title animation seen on various trailers.
    The preset behaviors and text animations in Motion aren't getting the result I want, so I decided to keyframe the animation...perhaps a bad idea. In LiveType, it is a simple matter of adding a new effect, and keyframing the scale. Everything stays center and flows well; nobody gets hurt.
    In Motion, I've tried keyframing scale and size, both affect the position of the text on the X axis. In order to have the text fill the screen on the first frame, I have to change its position along the X axis. Then, to make sure it is center by the "slam" frame, I have to keyframe the X axis. This sounds so simple and nothing should go wrong, however the X axis sort of "juggles" the text back and forth creating a sort of swoop from one side to the other. Even stranger, the X axis values do not fluctuate, they continue diminish, so I cannot isolate what is creating the swoop (I do have a number of filters, however). This sound familiar to anyone?
    I've even tried keyframing the position the whole way, but it doesn't work. Plus, the text is sort of crawling back to the side, favoring the left side of the screen (moving from right to left), not center. I don't have any Motion manuals because I did the Universal upgrade deal, so I am a little lost.
    Any help is, of course, greatly appreciated!
    Thanks In Advance!
    ~Athen

    It can be rather simple, if you will do your pan and zoom in Still Life, a very inexpensive and capable program, AND then bring that footage into Motion for whatever you want to do with it in special effects, etc. Of course, you must export from Still Life in iMovieHD or QuickTime before coming into Motion. It worked for me. Of course, there may be complications for you, of which I am unaware.
    Lucky Man
    PBG4 17   Mac OS X (10.4.6)  

  • Making a join seems simple but I can't get it to work

    Hi All,
    I have 2 tables LUGallery and LUSubGallery, the tables are related by the GalleyID field
    LUGallery
    Gallery ID
    ClientID
    GalleryName
    5
    50
    Australia
    8
    50
    Weddings
    12
    33
    Portraits
    4
    33
    Landscapes
    LUSubGallery
    SubGalleryID
    GalleryID
    GalleryName
    67
    5
    NSW
    68
    5
    QLD
    69
    8
    Reception
    70
    8
    Location
    87
    8
    Ceromony
    97
    4
    Rain Forest
    What I am try to do seems simple but I can't get it to work the way I want it.
    I am trying to write a query to display Galleries from the LUGallery tbl that have a Sub Gallery attached to them (ie. It's GalleryID appears in the LUSubGallery tbl)
    So the query for the above example would list Australia, Weddings & Landscapes
    I have tried to write code both with inner joins and nested queries but just can't get it right,
    Any help would be greatly appreciated.
    Thanks in advance
    Kris

    I just want to
    display the GalleryNames from the LUGallery tbl once
    Then you probably do not want include all the extra columns from the LUSubGallery table.
    It returns all of the records from both tables that Have
    the same GalleryID
    That is the way this type of JOIN works. It will return one record for each matched GalleryID. If you only want to display the unique gallery names you can either:
    1) Use an EXISTS clause.  It will return the distinct records from the main gallery table IF a matching record exists in the LUSubGallery table
    --- Not tested ---
    SELECT  LUGallery.GalleryID,
    LUGallery.GalleryName
    FROM    LUGallery
    WHERE   EXISTS (
            SELECT  *
            FROM LUSubGallery
            WHERE LUGallery.GalleryID = LUSubGallery.GalleryID
    http://www.techonthenet.com/sql/exists.php
    ... OR ....
    2) Use the DISTINCT operator to return only the unique combinations of the selected columns. Note: DISTINCT considers all columns in the SELECT list . So if you only want unique galleries, do not include the LUSubGallery columns in the SELECT list.
    http://www.w3schools.com/SQl/sql_distinct.asp
    Message was edited by: -==cfSearching==-

  • Validate through Reg Expression

    Hi,
    I have following requirement to be achieved through reg expressions.
    Need to write a boolean method which takes a String parameter that should satisfy following conditions.
    o 20 character length string.
    o First 9 characters will be a number
    o Next 2 characters will be alphabets
    o Next 2 characters will be a number.(1 to 31 or 99)
    o Next 1 character will be an alphabet
    o Last 6 characters will be a number.
    JDev 11.1.1.6.0

    Hi,
    Hope following links are useful
    https://blogs.oracle.com/shay/entry/regular_expression_validation
    http://www.vogella.com/articles/JavaRegularExpressions/article.html

  • CFINPUT Reg Expression Validation Pattern Help

    I've got a form with a non-required field that needs to meet
    some validation requirements (Numbers, Letters, 'space character'
    or 'blank, empty string' only) if the user chooses to fill it
    out...
    I'm using CFINPUT tag with the following settings, does my
    Reg Expression pattern look OK?
    REQUIRED="No"
    VALIDATE="regular_expression"
    PATTERN="^[a-zA-Z *]{1,40}$"
    MAXLENGTH="40"
    Thanks for any help. I'm v. new to regular expressions (10
    hrs education at Google Univ.)
    Sincerely,
    Paul Cross

    I think you want something more like this:
    ^[a-zA-Z0-9 ]{0,40}$

  • Reg expression help

    Can/will you help me make a regular expression for these characters? I want to replace eveyone occurance in a string contianing these chars
    \/:*"<>|
    with
    right now I am doing a string.replaceAll(...) on each char but I was wanting to combine that to one reg expression. What cha got? I am doing this b/c I am generating file names and those are not valid chars allowed in file names.
    Thanks
    Doopterus

      String regex = "[*<>/'\"\\\\]";In a character class (i.e., between the square brackets), "|" has no special meaning.

  • Seems simple enough right? Wrong!

    Okay hopefully someone on here can help me. I am using Illustrator CS5 and I am working on a document. I'm trying to put a logo on top of another item created by the pen tool. seems simple enough right? Wrong, the software will not let me use object>arrange>bring to front or Cmd ] and cmd [ is there something that i'm doing wrong? I've redrawn the shape and it still won't let me, I've brought in the logo again, it won't let me, i've done a host of other things and it still won't let me put that stupid logo on top of the cloud (what i drew with the pen tool)
    Thanks!

    Not sure what you mean. Why is there more than one layer?
    It could be that you intentionally created additional layers. It could be that you unintentionally created additional layers. It could be that you hit Cmd L some day. It could be that you pasted objects while Paste Remembers Layers was turned on. Or something else.

  • TS1587 will apple fix this issue free of charge? it seems that it is a known issue

    will apple fix this issue free of charge? it seems that it is a known issue
    my IMAC will not start at all.i press the power button and nothing happens and i bought it a year ago. i tried everything but it seems that it is a know problem reported by other users

    You still haven't provided any useful information, the  machine has a 1 year warranty and if it's less than 1 year old you can still buy AppleCare. If it is over 1 year old then you have missed your opportunity and will have to pay for any repairs. Known issues may only be known to you and a few others, it may not be wide spread at all. When posting you have to be very specific, we have no idea what you are thinking and cannot see or touch your machine so you have to be much more descriptive.
    Good luck,
    I'd recommend contacting your local Apple Store or AASP today and begin getting the machine fixed.

  • Minor yet annoying iTunes 7 install issues

    Has this happened to anyone else, or is this just an issue for me? iTunes 7 itself... works great, no complaints.... the only issue i got is the icons on the desktop, in the start menu, and in the actual program folders are windows "default image" pics..... is there a fix or is this a bug i missed in another topic?

    happened to at least one other person i've seen. still no definitive word on a cause, though.
    my current theory is that the registry keys for the new icons didn't write properly during the install. (when i've watched previous itunes installs, the icons show up in two stages ... first the Windows defaults you see, then the proper icons.)
    working on that theory, we might be able to get those icons to go in properly if we do a repair install of itunes.
    reboot the PC. go into Add/Remove programs. select itunes, and click "change". select "repair".
    do the new icons show up after the repair install? (they're kind of bluish rather than green.)

  • IPhone 5 camera has some minor, yet annoying issues. Help!

    Well, to get to the point my back camera has spots on it.. Whenever I try to take a picture there is a violet, purple, dash on it followed by some gray, shadowy circles. I tried to clean the lens and I blew on it a couple of times but it just doesn't seem to work. Has anyone else experienced this? I'm still under warranty so could they fix or replace this?

    I bought it from Amazon from someone who previously owned it and it came with a few light scratches, nothing major. I'm not sure if the previous owners caused this to happen because since I had it I have taken great care of it and just recently I found the spots on the lens. Is there still a possibility they can fix it? Thanks for your help! (:

  • Simple, yet not so. How can I just edit out part of a track.  Help says select the region in the timeline, but doesn't seem to be able to perform a most basic function of cut and paste

    Hi folks, anyone out there know how to select a region in the timeline so I can delete just part of a track.  I am making a soundtrack and want to fade in and out mp3's that I drag onto the track.
    Thanks.
    I feel dumb.

    Hermsboy wrote:
    how to select a region in the timeline so I can delete just part of a track [the region in the track]
    http://www.bulletsandbones.com/GB/GBFAQ.html#cutsection
    (Let the page FULLY load. The link to your answer is at the top of your screen)

  • So simple, yet so annoying: problem resizing anchored frame with grab bars

    Asked a question yesterday on how to 'snug' an anchored frame to an image. Got the answer and it works great (Esc-m-p)
    Now... the reason I needed to do this is that when I try to resize a frame with the grab bars, it 'jerks' as I move vertically or horizontally.
    What that means is...
    With borders on, the frame border is a dotted line.
    If I grab the left side of a frame and move my mouse to the right to make the frame smaller, the border doesn't move smoothly -- it jumps a distance of about 1.5 of those dotted lines. Thus I can't always make the frame fit nicely.
    Talked to another Frame user and she said that her's drags smoothly.
    So... am I missing a setting somewhere? Any thoughts would be greatly appreciated.

    ##&*!
    I was working over a VPN when I first experienced the problem... everything was slower than molasses. Set Snap off, did some other work, Frame crashed.
    Setting didn't persist, but everything had taken so long I forgot to check it.
    Gah. Yes, Snap off works wonders when it's *actually* off.

  • Help request: "simple" DVD, just pictures, delay issues

    Hi, I admit I'm a newbie regarding DVD authoring, but I'm trying to help a friend who just got her DVD SP 4 and needs to do a simple dvd with some of her paintings and some info about her.
    We've tried to follow the manual's instructions but now I think we need your help!
    So basically we have a project with a menu with 4 buttons (works, bio, cv, contact). No videos involved, it's all pictures based.
    We prepared the pictures in photoshop, and since I read about the slideshow problems in DVD SP, I created a track to show the slides.
    On each subpage (works, bio, cv, contact) I have created also a "button over video", using the subtitle (it's a "menu" word which links back to the menu), it seemed to us the easiest way to create an interaction.
    All the buttons in the project are text, no pics, no videos.
    Everything seems to work fine in the simulator. But when I save it as .img and test in the Apple DVD player, there are some unexpected delays when I click on, for example, the bio, cv, contact menu voices, before these pages to appear.
    It's strange also because these three pages are just made of one picture each at the moment, while the "works" consists of 6 pictures (and it has music also, while the other pages have no audio).
    We have also tried two different methods to build the project: the first version had all the contents on separate tracks (so one for "works", one for "bio", and so on).
    Then we tried with just one track, putting everything on it and using the marker/chapter/jump features to create a correct navigation.
    In this second case the final results are a bit better, but the delay is still there especially on the 3rd and 4th menu voice/chapter of the track ("cv" and "contact").
    Also, it's very annoying that the "button over video"/subtitle button appears before that delayed track/chapter appears, so if you have a tip about this issue too, we would appreciate it!
    Thanks!

    Whilst you are making a simple disc, you are using some advanced features, and for some folk they are just too glitchy to use.
    Here's a suggestion... get all of your images into .pict format at the correct dimensions for your video standard (720x480 or whatever) and number them sequentially. OPen the sequence in Quicktime and allocate five or ten seconds to each image and then save the result out as a piece of dv footage. Bring that in to DVDSP and add chapter markers at the start of each new image, or encode it to MPEG2 and bring it in (If you don't encode, DVDSP will handle that for you, but you might get better results if you do it yourself).
    Create some stories and place the relevant chapter markers into each (works, bio, cv and contact) so that only those markers play. Connect the menu buttons to the story containers (not the markers inside), and set the end jump and menu call for each story to go back to the relevant menu (and button).
    Make sure that your menus are not layer based - use simple overlay style menus or create them from the built in templates and palette items.
    You should then have avoided the slideshow settings in DVDSP and may get better playback performance. Keep in mind that there are always delays when you move from a menu to a track, and these differ according to the DVD player that you are using.

Maybe you are looking for

  • Send Error Report Message Coming Up

    I have re-installed iTunes almost 5 times now and nothing has worked. The message keeps popping up and when i press 'Dont Send" it automatically exits out of iTunes. I installed Malwarebytes-Anti Malware to see if that was casuing a problem. I even d

  • 5-screen (multi-monitor) nVidia xorg.conf -- my setup

    Hi. I would like to share my xorg.conf, since it took forever to get right. There isn't a lot of information out there for folks using > 2 monitors, or several graphics cards, or esoteric setups including rotation etc. I hope this will be useful; I w

  • MS Exchange 2013 certificate error.

    we just setup Exchange 2013 but I cant configure outlook . it brings two error messages. 1. There is a problem with a proxy server's security certificate. the name on the certificate is invalid or does not match the name of the target site. 2. The co

  • Font issues on PC and MAC...

    Hi, I have created a simple flash movie that appears in a pop up box from the main site. Anyway the flash movie contains text (dynamic) and i have had to make 20 different versions so kept the text as text.... This works fine on pc but when viewed on

  • I cant receive text from ppl that have iphone sine i got andriod

    i cant receive text from ppl in my contact that have iphone very frustated