• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

extract strings

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 281
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic