This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes extract strings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "extract strings" Watch "extract strings" New topic
Author

extract strings

Steeve Randria
Greenhorn

Joined: Sep 17, 2010
Posts: 16
Hello,

I have a file that I have put in a String and I want to extract spécific strings .

Here are one part of my file:



For exemple , in this part i want extract message_type and sp_api_name

I have tested with the Pattern class but that is very long and tedious if I have more research to do because I have to create each time an object pattern.



Thank you very much
Robin John
Ranch Hand

Joined: Sep 10, 2008
Posts: 270

What exactly do you want ? your question says "extract" and your code says "search and print"

#1 - the strings in "double quotes" or
#2 - you just want to print out "Found !" ?

for #1 there should be nothing easier than capturing the text in a group using Regular expression. (why do you think it will be long and tedious?)

for #2 - well, you have the answer and that can be refined using 'String' utilities.


Time is what we want the most, but what we use the worst. -- William Penn
Steeve Randria
Greenhorn

Joined: Sep 17, 2010
Posts: 16
Thanks for your answer

Indeed , i want extract the strings in "double quotes"

What do you mean by group pattern please ? Sorry , i am beginning with regex.

Thanks a lot for your help
Robin John
Ranch Hand

Joined: Sep 10, 2008
Posts: 270

Steeve Randria wrote:Thanks for your answer

Indeed , i want extract the strings in "double quotes"

What do you mean by group pattern please ? Sorry , i am beginning with regex.

Thanks a lot for your help



This below example might help you, but I recommend you to go through this -> Link to understand. Darryl Burke has beautifully explained the regex.

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

Steeve, it looks like your source is an email message. Can't you use JavaMail to parse the email, then use its methods to retrieve the multipart's body parts and from them the name?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Steeve Randria
Greenhorn

Joined: Sep 17, 2010
Posts: 16
Indeed , it ' s an email message
Thank you for your help, I went to see the side of java mail and that is exactly what I need: p
I ' haven ' t looked enough sorry .

At least I know regex now thanks to Robin John .

Thank you for yours help
 
 
subject: extract strings
 
Similar Threads
prog of multiple inputs
post html login
httpclient athentification issue
JPEG Image Upload
SSL, https and post