Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-16-2012, 03:32 PM   PM User | #1
sorlaker
Regular Coder

 
Join Date: Dec 2009
Posts: 166
Thanks: 23
Thanked 1 Time in 1 Post
sorlaker has a little shameless behaviour in the past
String matcher help!

Why this line of code outputs false?

Code:
System.out.println("Homer Simpson".matcher("\bSimpson$"));
I've tried so many different ways like.

Code:
System.out.println("Homer Simpson Lol".matcher("\bSimpson\b"));
System.out.println("Homer Simpson Lol".matcher("\sSimpson\s"));
System.out.println("Homer Simpson Lol".matcher("Simpson"));
System.out.println("Homer Simpson Lol".matcher("[ ]Simpson[ ]"));
Can someone help me to figure out this?
sorlaker is offline   Reply With Quote
Old 10-16-2012, 04:34 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
String doesn't have a matcher method; that should throw a compilation error. Perhaps you mean "matches", but you'll need to give it a full pattern. Perhaps with your lookup you should just use the contains() method.
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:46 PM.


Advertisement
Log in to turn off these ads.