Any bright ideas? (string parsing question)

Hi,
I need to put together some static methods for parsing and comparing strings in different formats. I've written the skeleton methods with some nice comments below:
public class ParsingTools {
    * This method should be able to convert a string that contains
    * a date in an arbitrary format, to a java.util.date.
    * E.G. '10.12.1998 4:15 AM', 'Jan 6th 1984', '1/01/00'
    * '24th Feb 1975 0530hrs'.  The boolean 'usa' parameter indicates
    * whether its usa style dates: mm/dd/yyyy, instead of dd/mm/yyyy.
    * @param inputDate
    * @param usa
    * @return
   public static Date parseStringDate(String inputDate, boolean usa){
      Date outputDate = null;
      return outputDate;
    * This method should be able to convert strings like:
    * "$10,000.45" to the double 10000.45, or even:
    * "'x=$$254,433,344.003'" to 254433344.00.  All kinds of
    * extraneous characters could be received, this method extracts
    * and returns the number part.
    * @param inputString
    * @return
   public static double parseMoneyString(String inputString){
      double outputDouble = 0.0;
      return outputDouble;
    * This method takes two strings, the first of which is compared
    * to the second to see if they are a close enough match.
    * E.G. " exerci$ed_" compared with "EXERCISED" should return
    * true, but "elephant" compared with "EXERCISED" should return
    * false.
    * @param inputString
    * @param compareString
    * @return
   public static boolean matchToString(String inputString,
                                       String compareString){
      boolean matches = false;
      return matches;
}Ok, the getting the double from the money string one is easy, just search through the string until you find some numbers, and strip out any commas.
If anyone has any ideas on a clever way of doing the date parsing, and the string compare one, or knows of existing methods to do these, I'd love to hear about it.
Many long hours of messing around with string operations await me otherwise!
Thanks

I need to put together some static methods for
parsing and comparing strings in different formats.
I've written the skeleton methods with some nice
e comments below:Why isn't java.text.DateFormat good enough for you? I'll bet they do it better.
I'd use Locale for currencies.
This is a case where stuff that's already available to you should be preferred. Why write your own when someone else has already done it better? You don't have to maintain it, either. JMO, of course.
>
public class ParsingTools {
* This method should be able to convert a string
ring that contains
* a date in an arbitrary format, to a
to a java.util.date.
* E.G. '10.12.1998 4:15 AM', 'Jan 6th 1984',
84', '1/01/00'
* '24th Feb 1975 0530hrs'.  The boolean 'usa'
usa' parameter indicates
* whether its usa style dates: mm/dd/yyyy,
yyy, instead of dd/mm/yyyy.
* @param inputDate
* @param usa
* @return
public static Date parseStringDate(String
ing inputDate, boolean usa){
Date outputDate = null;
return outputDate;
* This method should be able to convert strings
ings like:
* "$10,000.45" to the double 10000.45, or even:
* "'x=$$254,433,344.003'" to 254433344.00.  All
All kinds of
* extraneous characters could be received, this
this method extracts
* and returns the number part.
* @param inputString
* @return
public static double parseMoneyString(String
ing inputString){
double outputDouble = 0.0;
return outputDouble;
* This method takes two strings, the first of
t of which is compared
* to the second to see if they are a close enough
ough match.
* E.G. " exerci$ed_" compared with "EXERCISED"
SED" should return
* true, but "elephant" compared with "EXERCISED"
SED" should return
* false.
* @param inputString
* @param compareString
* @return
public static boolean matchToString(String
ing inputString,
String
String
String compareString){
boolean matches = false;
return matches;
}Ok, the getting the double from the money string one
is easy, just search through the string until you
find some numbers, and strip out any commas.
If anyone has any ideas on a clever way of doing the
date parsing, and the string compare one, or knows of
existing methods to do these, I'd love to hear about
it.
Many long hours of messing around with string
operations await me otherwise!
Thanks

Similar Messages

  • My airport express is still providing a link to my wifi network but I can't find my airport express on my macbook and i can't link to my bose speakers through it ... any bright ideas?

    My airport express is still providing a link to my wifi network but I can't find my airport express on my macbook and i can't link to my bose speakers through it ... any bright ideas?

    I'm not sure what you mean. You can't find the express to set it up.. or you can't find the network created by the express?

  • TS4036 hello there, my old phone was stolen and when trying to set up the new one using icloud it says: No backups available, even though i can see my last backup saved both on the new phone and my ipad, any bright ideas please?

    My old phone was stolen and when trying to set up a new one and restoring my last backup from icloud it says: No backups available, even though i can see my last backup is saved/still there both on the new phone and my ipad, can one only restore from an earlier saved backup during the intitial set up of the phone, or are you also able to restore/pick up an older version later after is i set it up as a new phone?  is any bright ideas please?

    Did you figure this out? I'm having a similar issue.
    Thanks!

  • ATI Radeon 4770 Fan Noise - Any bright ideas?

    Hi,
    I've an ATI Radeon 4770 graphics board installed on my Mac Pro (Early 2009, 16 gigs of RAM, OS 10.6.8).  The board works fine but the fan is noisy and goes on full tilt from a cold boot.  If I restart the Mac Pro then the fan will slow down and stop.  This is my current workaround.  Other than fan noise problem, everything else is working.
    Here's what I've done to troubleshoot so far:  Reset the SMC, zapped PRAM several times.  Updated OS to 10.6.8 from 10.6.7.  Verified HD and disk permissions. Extended Hardware Test has been passed. 
    Anyone any other bright ideas?
    Thanks,
    Midi.

    Brand new?
    Then you should be talking to the Vendor about why the card they sold you does not work correctly.

  • String parser question based on oracle grammer

    If i have a string like :
    update employee
    set wtKey = name||pno||id
    where id is not null
    Then my API should return this when i pass "||"
    name||pno||id
    I tried doing it using ' ' as dilimiter and check to see if the parsed string has || but that won't work when the above update cmd is written in the following manner:
    update employee
    set wtKey = name || pno || id
    where id is not null
    (or)
    update employee
    set wtKey = name|| ' ' ||id
    where id is not null
    Is there any API or third party stuff that can perform such operation instead of we parsing it based on some assumptions.
    Any help would be appreciated

    Matt,
    In simple terms, whenever you change some thing, its needed to be logged for the recovery. So when we change Oracle's datablock's data, we are creating one entry. The change has an undo entry also related to it, this would go to the Undo block. Now 'go' means we are updating undo block's current image(whatever it may be) with our current undo image for our transaction, a change hence has to be logged, second redo entry. Transaction table again has to be updated to maintain the entries of the current transaction, some records over there are updated, hence redo.
    The basic thing is that Oracle would make sure that we have all the changes, where ever they are done, logged in the log files for the crash. In case we wont have it, we wouldn't be able to perform recovery.
    A very simplified explanation :-).
    Aman....

  • Just rebooted ipad, and now facetime and i messaging not working. I put in my apple user id(email) and password code. says network connection not available, but my iphone works fine on the wifi.??i can text throug iphone, just not ipad??any bright ideas w

    Hi there. I have the ipad 3, and just last night had to reboot and do the upgrade, now my texting and facetime on it is not working...it states that when I click to activate it, and put in my user id(email) and passcode....that" could not sign in...please chekc network connection and try again".....well my Wifi connection is fine, and i can text and facetime fine from my iphone..just not the ipad now.....any ideas why it will not take my user id and passcode?...the passcode works fine on my iphone.

    Hello cohenj80,
    Thank you for the details about the FaceTime and iMessage activation issue you are experiencing on your iPad 3.  I recommend following the steps in this article when you are not able to sign into FaceTime or iMessage on your iPad:
    iOS: Troubleshooting FaceTime and iMessage activation
    http://support.apple.com/kb/ts4268
    Best,
    Sheila M.

  • I cannot sign in to FaceTime and because it was installed as part of mountain lion it can't be deleted and a a new one installed everything else works with my apple id  i am using a mac book pro any bright ideas

    Any help would be greatly appreciated

    Quit FaceTime:
    With the Finder active, hold the Option key down and click on the Go menu. Select Library. In that folder select the Preferences folder. In there look for these two files and trash them:
    com.apple.facetime.bag.plist
    com.apple.FaceTime.plist
    Now try FaceTime.
    p.s. there is a separate area for Macbook Pro discussions.
    https://discussions.apple.com/community/notebooks/macbook_pro

  • Since updating my iphone 4 to OS7 the keypad is slow to respond. Sending a text is now a chore!! Any bright ideas for restoring the response sped?

    since updating my iphone 4 to OS7 the keypad is slow to respond. Sending a text is a chore. Any ideas

    Settings - General - go down to Reset - Reset All Settings

  • Parsing question

    I feel like I know how to do this but I was wondering if anyone would have any better ideas.
    I have table that stores an id, sequence number, and column for text (4000 BYTES). What I need to do is parse, based on either one or two words on the text column. Now the complete text could be in 1 to a bunch or rows. All records would have the same id but increasing sequence numbers. My idea is to loop through the records based on id and have some logic to search for those rows or place all the records for an id into a collection and loop it. There has to be a better way to do it than this. This might be taking a step backwards but could I fetch all the records into a string and parse it. I think this could cause memory problems if there are a lot of row with the same id.
    caveat: I can't change the column to something else.
    Any help would be appreciated.

    you can try
    select *
    from
      (select your_id_col,
        dbms_xmlgen.convert(extract(xmlagg(xmlelement(e, your_text_col || ' ') order by your_sequence_col) ,'//text()').getclobval(),1) txt
      from your_table
      group by your_id_col
    where lower(txt) like '%your_search_text%' and lower(txt) like '%your_search_text_2%' and .....

  • Tough Parsing question???

    Please try to help me with the following parsing question.
         I have an exert from the 2000 Tiger/Line Census files that looks
         something like this:
         0001     A     Libby     Ln     -92.99999+25.87787      -92.87679+26.65543
         0002     A     Capri     Ave     -93.32343+23.3332 3      -24.34444+34.22222
         0003     A     Minster Grove Ln     -93.23433+22.2223432     -98.343343+23.34332
         0003     A     Houston Ave -91.99892+22.323322     -98.434543+33.33233
         0004 A I-10          Int -91.23234+32.343232     -97.333233+34.22222
         0005 C     Trenton Springs Ct. -90.22232+33.222123          -91.234432+23.33221
         I want to parse it so I can enter it into an SQL database.
         Normally this would be an easy task but, the file is not comma
         deliminated. Usaully I could just break it apart at the white space
         but as you can see above, some of the street names (the third column)
         have whitespace in the text. I have almost declared it impossible
         and am about to give up an buy prepackaged/parsable software.
         I will feel very small if I have to do that.
         Thanks for any help,
         Ian

    public class CensusParser
         String[] census = {     "0001     A     Libby                       Ln     -92.99999+25.87787                 -92.87679+26.65543",
                                  "0002     A     Capri                       Ave     -93.32343+23.3332 3                -24.34444+34.22222",
                                  "0003     A     Minster Grove    Ln     -93.23433+22.2223432             -98.343343+23.34332",
                                  "0003     A     Houston               Ave    -91.99892+22.323322           -98.434543+33.33233",
                                  "0004    A       I-10                     Int    -91.23234+32.343232                 -97.333233+34.22222",
                                  "0005   C     Trenton Springs Ct.    -90.22232+33.222123           -91.234432+23.33221" };
         int cur, flds;
         String n = "";
         void parse() {
              for (int x=0; x<census.length; x++) {
                   flds = 0;
                   cur=census[x].length();
                   n = "";
                   for (int y=census[x].length()-1; y>=0 && flds < 4; y--) {
                        if (census[x].charAt(y) == '-' || census[x].charAt(y) == '+') {
                             n = "," + census[x].substring(y, cur).trim() + n;
                             cur = y;
                             flds++;
                   n = census[x].substring(0, cur).trim() + n;
                   census[x] = n;
                   System.out.println(n);
         public static void main(String[] args) {
              CensusParser cp = new CensusParser();
              cp.parse();
    }Not very efficient, but it works!
    Mark

  • I have inadvertently infringe copyright on facebook and they have subsequently barred me from uploading any more videos. The question I need answered is ( and not able to find the answer on any of you help pages).....  Do the following have free copyright

    I have inadvertently infringe copyright on facebook and they have subsequently barred me from uploading any more videos.
    The question I need answered is ( and not able to find the answer on any of you help pages).....
    Do the following have free copyright to publish on facebook and U Tube?
    1.Garage band sounds?
    2.Slide show...Sample music and Theme music?
    3.iMovie...iMovie sounds and iLife sounds ie.Medal Ceremony and Memorial etc?
    I note one can publish to shared net places directly from iMovie so one assumes these are copyright free for non-profit making and non-comercial use.
    It is impossible to contact apple direct.No email address.We put our selves at risk without this knowledge and like applemac, facebook will not communicate direct.Will applemac please take responsibility for copyright/the above that they are all too willing to sell to us but not support us with that knowledge.
    I have Mac OS X Snow Leopard version 10.6.2 (2009 bought in 2010)

    Thank you Klaus1.The large font, I copied and pasted from my mail box.I'm visually impaired...not to a huge degree but it helps to use the large font.I believe you are right about the copyright on the imac stuff but if facebook decide otherwise, you have to reply electronically to their challenge.If you can't provide a reference directly from the copyright owner then they remove the video.I believe this is a programmed response and no human is involved which now makes it impossible for me to get my video uploading restored.They detect added soundtrack automatically and then challenge.There are many others in the same boat and facebook will not communicate.They have various discussion sites on which I have left messages including Mark Zuckerbergs own facebook but I don't think anyone from facebook ever reads them.I intend to start a second facebook which I can use purely to get my videos uploaded as a lot of my friends enjoy them BUT don't want fall foul of their programming again.If only iMac would put something on the net to this effect.I think it is so unfair that with modern technology it is impossible to contact these large conglomerates personally and receive an email response.I tried emailing [email protected] but I got a failure notice.If you have any ideas on how to get verification from apple direct, I would be very grateful.Thank You.

  • XML string parsing

    Is there any class method to parse an XML string into tags and contents?
    I have a response in XML and would like to read a tags contents.
    Thanks

    Hi KP,
    look at the iXML library. http://help.sap.com/saphelp_nw04/helpdata/en/47/b5413acdb62f70e10000000a114084/frameset.htm
    Depending what release you are developing on you might also want to look at SImple Transformations.
    Cheers
    Graham

  • Oracle date string parser

    I really want that oracle can change their command parser engine to be smart enough especially for date string parsing.
    currently the engine will throw error when we type a date string as (for example) '10/10/10', while this command can be accepted in MS-SQLServer.

    AMaster wrote:
    i have stored three numbers in three different variables and want to join all of them to concatanate:
    http://docs.oracle.com/cd/B19306_01/server.102/b14200/operators003.htm
    make a date string , kindly help me with this.
    Edited by: AMaster on Sep 6, 2012 4:12 AMto_date:
    http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions183.htm
    How to ask a question:
    SQL and PL/SQL FAQ

  • Quartz Composer - Effects of Other Cards? Any New Ideas?

    I have read the discussions here about Quartz Composer, and noticed a mix of difficulties:
    1 hardware restrictions (G4 or video card)
    2 can't get preview (white screen), but can get render
    3 can get preview, but can't get render (white screen)
    4 can't get either preview or render
    5 get greyed or coloured results in renders
    I'm suffering 4 - no preview or render - but not 1 - I have a G5 2G Dual Processor, with an ATI Radeon Pro 9600. (I see ripples when widgets launch.)
    In this context, are there any new ideas?
    One observation: to find out the name of my video card, I ran system profiler, to be reminded that I have:
    - an old ATI card driving a second monitor in a PCI slot
    - an Alchemy TV card also in a PCI slot
    I know it's tempting to blame the cards for the iMovie difficulty, especially since we are talking about a video problem, and both are video cards, so I want to ask:
    - are there any people with these kinds of cards having no problem at all?
    - are there any people with similar cards experiencing similar problems?
    G5 DP2G & G4/466   Mac OS X (10.4.5)   1.5 G RAM

    "I know it's tempting to blame the cards for the
    iMovie difficulty, especially since we are talking
    about a video problem"
    Have you tried pulling out [Alchemy TV and second monitor] cards, just to rule
    them out as a source of the problem?
    No... my thinking is that I'm an amateur iMovie user, and in the end I would feel more comfortable with my second montor and (very occasionally used!) TV than with a fully working iMovie. Hence my questions were directed at finding out whether others had:
    - these problems without cards being fitted
    - no problems despite cards being fitted
    G5 DP2G & G4/466   Mac OS X (10.4.5)  

  • I downloaded a trial of photoshop.  It runs for a minute or so, then a message displays saying that photoshop has stopped.  No error codes, just the message. I have exhausted the "try this" stuff that I can find.  Any other ideas would be appreciated.

    I downloaded a trial of photoshop.  It runs for a minute or so, then a message displays saying that photoshop has stopped.  No error codes, just the message. I have exhausted the "try this" stuff that I can find.  Any other ideas would be appreciated.  I would also like to know what some alternative applications might be.  This trial does not give me confidence in Adobe's product.

    I saw a similar question deeper into the forum right after I posted.  I followed the fix steps and it took care of the problem.
    Thanks for getting back to me.  I am good to go.

Maybe you are looking for

  • How to map 64 bit bars in Fcode plugin driver on Solaris T5440

    Hi all, I am trying to develop a FCODE driver for my NIC card on Solaris T5440. The card has 3 different memory mapped io regions.BAR1 is 16k 32 bit and BAR2,3 128K 64 bit and Bar4,5 64bit 128k.I could successfully map the BAR1 and BAR2,3 and read th

  • Performance tuning in FI

    Hi , Could any one suggest, how I can increase the performance in FI , when i would be generating tax reports? and what are the tables to be used for tax generation?

  • How could i transfert video from my computer to my ipod

    how could i transfert video from my computer to my ipod

  • RFBIBL00 usage

    I am hoping someone can help me out with the usage of RFBIBL00 with some sample code and tips.  I am trying to submit the program with a flexible dsn generated from file_get_name with no success. Also a format for the subsequent submission of RSBDCSU

  • Question: JDev10g features

    1) Navigator What is the difference between the "Applications - Navigator" and the "System - Navigator" (Besides the allowed use of "Directory tree" and "File List" viewstyles, and the "Show all files" option)? 2) Connections, SCM/Designer And also,