aspose file tools*
The moose likes Java in General and the fly likes extracting string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "extracting string" Watch "extracting string" New topic
Author

extracting string

Saral Saxena
Ranch Hand

Joined: Apr 22, 2011
Posts: 202

Hi Folks,

I need your advise in one case that i am scanning a card , it may be any card but if it contains any number begging with 'LYL' then it should be treated specially, rest all we ignored , so what logic we have that we scan all the cards and check that whether it is begging with 'LYL' series , if yes then e will treat them specially rest we ignored...

complete card format would be LYL01016278572011000000012




Is there any other way in java to achieve this..! through regular expressions or through regex pattern ...!! please advise..!!


Anayonkar Shivalkar
Bartender

Joined: Dec 08, 2010
Posts: 1509
    
    5

Hi,

What you are trying to achieve can easily be done with startsWith method of String class.


Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
Saral Saxena
Ranch Hand

Joined: Apr 22, 2011
Posts: 202

Anayonkar Shivalkar wrote:Hi,

What you are trying to achieve can easily be done with startsWith method of String class.


Hi ,

Thanks a lot, could you please also show me how the above code can be converted with startsWth() that will be a great help..!! thanks a lot..!!
Manoj Kumar Jain
Ranch Hand

Joined: Aug 22, 2008
Posts: 191

look at the startsWith method in String class, there is nothing much to use this method in the above code..
Method name itself suggest what it does...Just put it in if condition..


Do not wait to strike till the iron is hot; but make it hot by striking....
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4642
    
    5

This appears to be at least the third thread in a series. Time for you to give the String and Pattern API a thorough read.
http://www.coderanch.com/t/572056/java/java/extracting-portion-number-string
http://www.coderanch.com/t/572089/java/java/masked-String


luck, db
There are no new questions, but there may be new answers.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Darryl Burke wrote:This appears to be at least the third thread in a series. Time for you to give the String and Pattern API a thorough read.
http://www.coderanch.com/t/572056/java/java/extracting-portion-number-string
http://www.coderanch.com/t/572089/java/java/masked-String



Agreed. Regular expressions is not something that can be learned from a forum. If you are going to insist to use it, as a learning exercise, in place of simpler options, then we recommend actually picking up a tutorial / book.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
Consider Paul's rocket mass heater.
 
subject: extracting string