String.replaceAll how far can you take it?

Hi,
I want to do 2 (or 3) simple string conversions like this:
1. in: "CustomerOrderHistory" out: "customer_order_history"
2. in: "customer_order_history " out: either "CustomerOrderHistory" or "customerOrderHistory" (either ok)
Actually number 2 is no problem, I did it like this:
public static String mixedCaseToCaseInsensitiveLower (String input) {
     return input.replaceAll("([a-z])([A-Z])", "$1_$2").toLowerCase();           
}No problem works fine, but now I'm wondering if it's possible to implement case 1 in a one liner like that.
Of course, I I can see how I could code it with a specific routine, but I'd like to know if the replaceAll method can do it for me.
So far I have this:
return input.toLowerCase().replaceAll("((_)([a-z]))", "$1")This just removes any underscores that occur before a lower case character, but I don't see any way to tell it that the character after the underscore, ie "$1" should be upper cased.
It may be that I'm asking too much, or it may be that I've missed something... tell me what you think,
Thanks
Iain

You're asking too much. :/
You have to process the replacement text before it gets inserted into the result string, which means you can't use replaceAll(). You can, however, do it he long way, using Matcher's appendReplacement() and appendTail() methods:  private static Pattern p = Pattern.compile("(?:$|_)([a-z])");
  // to leave the first letter lowercase, use "_[a-z]"
  public static String toCamelCase(String input)
    Matcher m = p.matcher(input);
    StringBuffer sb = new StringBuffer();
    while (m.find())
      m.appendReplacement(sb, m.group(1).toUppercase());
    m.appendTail(sb);
    return sb.toString();
  }Of course, with about the same amount of effort, you do the same thing with indexOf(), charAt(), and a for loop. Now, if we could combine Matcher with the new Formatter (sprintf) class, we could really have some fun...

Similar Messages

  • OWB 10Gr2, how far can you take the Data Profile Editor?

    After working with the Data Profile Editor a bit, it seems like it has a lot of potential, but I can't quite figure out how to get it to do the thing I'm most in need of.
    The problem: Tables in a source database that have CHAR columns instead of VARCHAR columns (also date fields stored as text in the format YYYYMMDD).
    After generating a couple of correction maps, it seems like I should be able to do these simple transforms in the correction (it converts fields that look like numbers but stored in text with the to_number function in the resulting map), but I can't figure out where exactly to tell it to change the data type from CHAR to DATE, or where to tell it to TRIM the CHAR column before converting it to VARCHAR.
    The only alternative that I can see is a mapping with dozens and dozens of expression operators to TRIM and TO_DATE the fields. This is a nasty and time consuming process.
    Thanks in advance,
    Eric
    Any advice?

    In chapter 14 of the OWB User Guide, it mentions that the Data Profile Editor can be used in such a way:
    "Data rules can be used in two ways to cleanse data and correct schemas. The first way is to convert a source schema into a new target schema where the structure of the new tables strictly adheres to the data rules. The new tables would then have the right data types, constraints are enforced, and schemas are normalized. The second way ..."
    It doesn't go into any deatil how to do any conversion of data types or data with data rules, however.

  • GTX675M Overclocking - how far can you go?

    Seems hard to find numbers about this one.
    I hae a GT60 with the GTX675M
    But how far have you guys been overclocking this card?
    So standard clocks are 632/1500
    I've already pushed it to 735/1725
    Tested it on Crysis 3 and it worked without glitches. Temps were around 93°C. Seems I can push it even harder? But to late to test.
    I did not turn on the fan-button, so fan-speed was controlled by motherboard.
    I did some OC testst with Kombustor and it locked up when clocking it lower then what I did above, don't know why, so I thought I couldn't get higher then 700/1700. Seems I can.
    PS.: If someone else found numbers from this card in laptops, let me know!
    PS2.: I guess when the 675M breaks, I can put in a 675MX, not? Same slot and all... Should also run even cooler I think, since it's a Kepler then.

    Depends on what you want and what you are willing to sacrifice  
    If lower RAM speed is OK, select 5:4 to maintain DRAM within spec. You should be able to get 3.2GHz easily - possibly higher too if you have the right components and tweak it right  :D
    You may also need to review cooling if heat tends to rise with extreme loads and major overclocking.

  • New to Flash - How far can I take video/image manipulation?

    Hi,
    I'm new to the flash/flex world and am considering using
    Adobe products for an interactive site. My understanding of all the
    various product, however, is still evolving so it's safe to assume
    and rather basic level of understanding of Flash, Flex, their
    related products and relationships to each other.
    I have a couple of questions before diving in, and any advice
    or pointers to docs would be most appreciated.
    - When the user pauses a video clip, can we pinpoint the
    exact frame in the video (not frame in swf) on which they paused?
    - Is it possible to take a screenshot of the current video
    frame?
    - How much "processing" can we do on the image? For example,
    can I get access to individual pixel data, and is it reasonably
    fast to manipulate?
    Thank you in advance!
    Sean

    SeanFlash,
    > - When the user pauses a video clip, can we pinpoint
    > the exact frame in the video (not frame in swf) on which
    > they paused?
    Seeking in FLV videos applies to keyframes, so it will
    depend on how
    many keyframes you include in that FLV when you encode the
    video. The
    greater the number of keyframes, the more precision -- but
    the greater the
    filesize.
    > - Is it possible to take a screenshot of the current
    video
    > frame?
    Flash doesn't have access to the OS deeply enough to take a
    screenshot,
    but you can certaily use the BitmapData class to copy pixels
    from one object
    to another. You can even manipulate those pixels.
    > - How much "processing" can we do on the image? For
    > example, can I get access to individual pixel data, and
    is
    > it reasonably fast to manipulate?
    These are subjective questions, so it's hard to answer them.
    I've seen
    examples of "fire" effects (particles) added dynamically to
    live webcam
    captures. I've seen blendmode effects and filters (glow,
    etc.) applied to
    video.
    David Stiller
    Adobe Community Expert
    Dev blog,
    http://www.quip.net/blog/
    "Luck is the residue of good design."

  • How far can you push java mathematically

    Can you do calculous in java. Like differentiation etc.

    If you ask some folks in this forum they will tell
    you that GUI-builders are terrible, if you ask others
    their opinion, they will tell you they love them, and
    in the mean time this thread will degenerate into a
    debate on the relative merits.I think the debate has nothing to do with the merits of GUI builders and everything to do with whether or not he can do mathematics WITHOUT a sophisticated UI. I think he'll have his hands full solving the calculus problems he has in mind without adding to his troubles by worrying about a UI.
    Do it with plain text at first. Once you have that working, then worry about the UI. It'll be a good way to separate UI from the rest of the problem - a good practice.
    %

  • How 3d Can you take it?

    I recently put together this bit of work. http://www.vimeo.com/15227417
    in the older days Id have done stuff like that in maya, but motion can handle it, and the work flow feels a little more artistic. But I still love my 3D.
    So I was wondering, how much further I could take it? For me the problem is the obvious lack of depth to objects, How could one do something a little bit cylindrical? What interesting tricks and tips do you have on making interesting things with 3d in motion.
    Adam

    Yah - the 3D primitives available in Motion 4:
    are pretty basic. All of them constructed from variations on the Sphere replicator. You can map a still image onto the cylinder, and the cone (sort of), and you can put images/movies on each side of the cube, but the sphere basically has only columns, so you can't map a broken up image onto it.
    Here's the project.
    Patrick

  • How far can you stretch Pages?

    I was just recently commissioned to design and layout a 48 page quarterly magazine. I'm an experienced designer and my first inclination was to use Adobe InDesign. I own iWork, but have thus far left it untouched.
    Are there any Pages pros around here? If so:
    1. Do you think Pages would be capable of producing a quality 48-page publication? That is, something on par with InDesign?
    2. I realize that it is designed to be easy-to-use. Is it - like many other iApps - capable of being pushed beyond that ease of use? How much creative freedom does it allow?
    Thanks in advance for any feedback!

    I've used InDesign and Word much less in the last two years than I had in the past and but there are two reasons why I wouldn't embark on your project with Pages: 1) 48 pages and 2) you say you've left Pages untouched this far. What I'd recommend instead is that having created the document in InDesign, at some point you recreate at least part of it with Pages.
    Having picked up iWork '05 and spent a weekend playing with it, I decided to recreate a tri-fold brochure I'd already done in InDesign. It was a breeze and when I dropped by the print shop to see how it printed I was quite pleased. Of course the shop didn't have Pages but I gave them my PDF output. I'd been putting off redesigning the monthly tech newsletter and emboldened by the brochure experiment, I grabbed Pages and did the redesign. I've been using Pages for that newsletter and another I write.
    However, every summer I do the local county fair's yearbook and my temple's yearbook. I didn't even think about doing them in Pages. It all boils down to control for me. Pages is sort of a neither this nor that kind of creature and one of my frustrations has always been the inability to grab objects conveniently. Layers is another frustration. Further, while I've never had any speed issues with Pages, I never doubted that others did and I felt certain that at some point, with a complex document I'd begin to find it.

  • Animation... how far can you go?

    Hi there. I wanted to know if it´s ok to work on basic cartoon animations with MOTION. What we are trying to do is a 2 minute short animation about a clown... nothing complicated. Something maybe like this: http://www.youtube.com/watch?v=6xTeazHHHwk
    If not what software do you recommend?
    Thanks for the help

    i think you could do that primarily in Motion 3 yes. You could animate the mouth with audio behaviours to the V/O if you wanted. You may want to do your drawing in illustrator and convert to Motions shape layers for the most flexibility. There is a script here to do it.. http://www.motionsmarts.com/downloads/IL2MotionShape.zip
    After Effects would also be more than capable, using the new puppet tool might be a help here.

  • Since the iPod Lightning connection is not supported, how can you take videos from your iPod 5th Gen to your tv?

    Since the iPod Lightning connection is not supported, how can you take videos from your iPod 5th Gen to your tv?

    Lightning TV out
    - Via Airplay to an Apple TV.
    or one of these cables.
    - http://store.apple.com/us/product/MD826ZM/A/lightning-digital-av-adapter?fnode=3 a
    - http://store.apple.com/us/product/MD825ZM/A/lightning-to-vga-adapter?fnode=3a

  • HT1351 Can you take the music off the existing library on the ipod and sync it to a new itunes library?? and if so how do you do this???

    Can you take the music off the existing library on the ipod and sync it to a new itunes library?? and if so how do you do this???

    See this excellent User Tip from another forum member turingtest2 on how to recover content from your iPod back into iTunes.
    https://discussions.apple.com/docs/DOC-3991
    B-rock

  • Can you take a iPad 3rd generation to a Apple Store for a refurb and how much would it costCa

    Can you take a iPad 3rd generation to a Apple Store for a refurb and how much would it costCa

    Hello, SJMMMM.  
    Thank you for visiting Apple Support Communities.  
    I would need clarification on what issue you are experiencing with your iPad to provide a better answer to your question.  However, here is the some information that you may find helpful when an iPad needs to be serviced.  
    Repair & Service
    -Jason H.  

  • How can you take a video including music from IPhoto and put it onto a disk?

    How can you take a video including music from IPhoto and put it onto a disk?

    You need burn software which will author/encode the movie so it can be viewed using any DVD player - there is iDVD (still available as part of the retail 09 or 11 iLife disks at online resellers including ebay and Amazon) or Roxio Toast ($$) or Burn (free, but very basic).

  • How can you take off the volume limit?, How can you take off the volume limit?

    How can you take off the volume  limit on iPod touch ?

    Which "volume limit" do you mean?
    All iPods have a volume limit feature that you can set yourself and on your iPod, go into Settings/Music/Volume Limit. There, you can set the volume limit to maximum, which is the same as turning it off.
    However, if you mean the EU (European Union) volume restriction, on all iPods sold inside the EU, you cannot turn that off.

  • When I sync my photos to iPhoto from my iPhone 4S it like saves about 200 on my phone. I really don't like that because they're like really old and stay the same... Can you take that setting off? Or just make it you most recent pictures instead?

    When I sync my photos to iPhoto from my iPhone 4S it like saves about 200 on my phone. I really don't like that because they're like really old and stay the same... Can you take that setting off? Or just make it you most recent pictures instead? It's really annoying because they're like year old pics

    it had to do with Maverick/Aperture not supporting the same date formats as before in Smart Albums when I upgraded.
    Smart albums based on dates have always been problematic, if you use smart settings that require a date string to be entered. How the date string will be interpreted, will depend on your settings in the System Preferences > Language&Text > Advanced > Dates formats and the "Region".
    It is much safer to use "Calendar" rules in Aperture instead of "Date" rules with date-strings. Calendar rules will remain valid, if the region settings are changed in the System preferences.

  • HT201364 Xserve (Early 2008) with Snow Leopard 10.6.8: How far can I upgrade ? Can I upgrade to an OS X Server version? Is any OS X Lion version compatible?

    How far can I upgrade ?
    Can I upgrade to an OS X Server version?
    Is any OS X Lion version compatible?

    Open the Mac App Store and try downloading Yosemite. If you get told it's incompatible, the computer's also incompatible with Mountain Lion and Mavericks; if desired, choose About this Mac from the Apple menu, check if the computer has at least a Xeon or Core 2 Duo(not Core Duo) CPU and 2GB of RAM, and if it does, click here and order a download code for Lion 10.7.
    Back up your data and check your applications for compatibility before upgrading. In particular, Mac OS X 10.7 and newer don't support PowerPC programs such as versions of Microsoft Office prior to 2008.
    (123636)

Maybe you are looking for

  • IN operator is not working correctly while calling,although pl/sql procedur

    CREATE or REPLACE PROCEDURE TEST( idListCommaSeparated IN VARCHAR2 AS CURSOR c_emp IS SELECT first_name,last_name,start_date From Employee where id IN(idListCommaSeparated); r_emp c_emp%ROWTYPE; begin insert into temp1 values('B',sysdate,sysdate,'A')

  • How can I attach a document to the answering email form?

    How can I attach a document to the answering email form?

  • Problems adding and removing dual monitor

    using FCE to do some light editing at work. continually need to flip between a single and dual monitor setup due to other things i need to do on a different computer. having problem with FCE not moving all windows back to the main monitor after remov

  • LDAP netgroup with SSH

    I am planning to intergrate LDAP netgroup to SSH in Solaris 10 (SUN native SSH SUNWsshxx) in order to restrict unauthorized users to ssh in. Any advice?

  • Composition vs Delegation

    Hi, Composition is about the relationships between objects. Delegation is about passing work from one object to another. So both are different. Example for Delegation:- class RealPrinter { // the "delegate" void print() { System.out.print("something"