Answer the question
In order to leave comments, you need to log in
How to create a regular expression in JAVA for a block of multiple lines?
There is the following text:
!re
=.id=*1
=.nextid=*2
=name=script1
=owner=admin
=policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api
=run-count =0
=source=
=invalid=true
script1
script1
=owner=admin
=policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api
=run-count=0
=source=
=invalid=true
Answer the question
In order to leave comments, you need to log in
The asterisk is needed not greedy in the second case.
Pattern p = Pattern.compile("^.*name=(.*?)$", Pattern.MULTILINE | Pattern.DOTALL);
Pattern p = Pattern.compile("^.*name=(.*)\n=owner.*$", Pattern.MULTILINE | Pattern.DOTALL);
This is how it happened, but it's clearly somehow crooked ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question