Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

extract strings

 
Steeve Randria
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 281
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Steeve Randria
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 281
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20668
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Steeve Randria
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic