>>>> I am trying to create a new profile management system, and I have some
>>>> regular expression I used in PHP e.g. "<\/b> (.*?) aar"
>>>> Where I get the String between and aar
>>>> Is there any way I can do this in Java?
Yes.
Eric Sosman wrote:
>>> There's a splendid new on-line system for answering this
>>> kind of question. Visithttp://www.google.com/(that's two O's
>>> and one G, not the other way around) and enter a search for, oh,
>>> gee, I dunno, maybe "Regular expression in Java". Chances are
>>> Very Good Indeed that they'll have something you can make use of.
Lew wrote:
>> You mean, like
>> <http://java.sun.com/javase/6/docs/api/java/util/regex/package-frame.html>
>> ?
Did you read this link? Have you read through the descriptions of the various
types and methods in that package?
> Yes, but I don't know I should make use of it in my situation
Neither do we. You haven't seen fit to share any details. What exactly is
your situation?
I should think you'd make use of it in exactly parallel a way to how you use
the PHP equivalent.
If you can't share these details, then Eric's advice that GIYF, and reading
the Javadocs, and reaching conclusions from there is really the only way to
go. Have you tried this?
Part of the essential skill set of the competent programmer is to reason how
to use available APIs, to assemble them into the logic one wishes to embody.
What is the logic you wish to embody?
What are your specific questions about the Java regex libraries?
What have you tried so far?
What results has that achieved?
Read <http://sscce.org/>
GIYF. JDAYF.

Signature
Lew
The87Boy - 03 Feb 2010 18:13 GMT
> >>>> I am trying to create a new profile management system, and I have some
> >>>> regular expression I used in PHP e.g. "<\/b> (.*?) aar"
[quoted text clipped - 16 lines]
> Did you read this link? Have you read through the descriptions of the various
> types and methods in that package?
Yes I have
> > Yes, but I don't know I should make use of it in my situation
>
> Neither do we. You haven't seen fit to share any details. What exactly is
> your situation?
I use the regular expression "<\/b> (.*?) aar" in PHP to get the
String between the space and aar (the .*)
I want to use it in the same way in Java
I could of course split the String up 2 times
> What are your specific questions about the Java regex libraries?
Whatever it is possible to find a String from another String by a
regular expression in Java
> What have you tried so far?
I have tried many thing, but it seems that I have to split the String
Knute Johnson - 03 Feb 2010 18:37 GMT
>>>>>> I am trying to create a new profile management system, and I have some
>>>>>> regular expression I used in PHP e.g. "<\/b> (.*?) aar"
[quoted text clipped - 34 lines]
>
> I have tried many thing, but it seems that I have to split the String
import java.util.regex.*;
public class test {
public static void main(String[] args) {
String str =
"Some where over the </b> There is a duck aar from here to there";
Pattern p = Pattern.compile("</b> (.*?) aar");
Matcher m = p.matcher(str);
if (m.find())
System.out.println(m.group(1));
}
}
You don't have to split the string. I don't use PHP but it looks like
you need to escape the forward slash? That is not required in Java.
Look at Pattern and Matcher in the docs.

Signature
Knute Johnson
email s/nospam/knute2010/
The87Boy - 03 Feb 2010 18:48 GMT
On 3 Feb., 19:37, Knute Johnson <nos...@rabbitbrush.frazmtn.com>
wrote:
> >>>>>> I am trying to create a new profile management system, and I have some
> >>>>>> regular expression I used in PHP e.g. "<\/b> (.*?) aar"
[quoted text clipped - 53 lines]
>
> Look at Pattern and Matcher in the docs.
Oh, it was because I have to use Matcher's group with 1 instead of 0
Lothar Kimmeringer - 03 Feb 2010 18:52 GMT
> You don't have to split the string. I don't use PHP but it looks like
> you need to escape the forward slash? That is not required in Java.
If PHP is similar to Perl, the slash indicates a regular
expression, but you can change that to something else as well.
One additional note. If you want to escape a special character
you have to escape the escape-character in the String, so
Pattern.compile("<\/b> (.*?) aar");
wouldn't work,
Pattern.compile("<\\/b> (.*?) aar");
is to be used instead. Otherwise the compiler most likely
complains or - even more bad - creates a wrong regex.
Regards, Lothar

Signature
Lothar Kimmeringer E-Mail: spamfang@kimmeringer.de
PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)
Always remember: The answer is forty-two, there can only be wrong
questions!
The87Boy - 03 Feb 2010 19:41 GMT
On 3 Feb., 19:52, Lothar Kimmeringer <news200...@kimmeringer.de>
wrote:
> > You don't have to split the string. I don't use PHP but it looks like
> > you need to escape the forward slash? That is not required in Java.
[quoted text clipped - 9 lines]
> is to be used instead. Otherwise the compiler most likely
> complains or - even more bad - creates a wrong regex.
I think the right pattern is "</b> (.*?) aar" as we are taking
about the HTML-tag </b>