Menu

assign 'chops' to variables

Help
2005-04-06
2013-06-12
  • Nobody/Anonymous

    Hi, is there a way like in perl regex, to define for example, that a string found between two identifyer groups should be assigned to a variable ?
    e.g -     this is the text. the rest.
    get the string that is enclosed within two 'the' strings and assign it to a variable

     
    • Nobody/Anonymous

      Hi!

      String myStr=null;
      Matcher m=new Pattern("the(.*?)the").matcher("this is the text. the rest.");
      if(m.find()) myStr=m.group(1);

      hope this helps...

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.