A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Java
»
Java in General
Author
Regular expression help needed
Prashant Langade
Ranch Hand
Joined: Jul 01, 2009
Posts: 70
posted
May 29, 2010 04:51:32
0
Hi
I dont have much knowledge of Regular expressions.
My requirement is to match the
string
starting and ending with underscore i.e "_"
that means
if i have strings as
1> _abc_
2>_abc_av
3>ab_abc_
4>_pqr_
then only _abc_ and _pqr should be able to match the
pattern
.
Can any one please help me?
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35232
7
posted
May 29, 2010 04:56:45
0
Something like "^_.*_$" should do the trick.
Android apps
–
ImageJ plugins
–
Java web charts
Eoin Brosnan
Ranch Hand
Joined: Dec 12, 2009
Posts: 37
posted
May 30, 2010 13:09:01
0
Ulf Dittmer wrote:
Something like "^_.*_$" should do the trick.
"^_.*_$" will also match __ (two underscores, with no string). If you don't want that then just replace the *(which means zero or more) with +(which means at least 1 or more). "^_.+_$"
I agree. Here's the link:
http://aspose.com/file-tools
subject: Regular expression help needed
Similar Threads
javascript event ?
Using contains/equals/== with random characters?
Regular expression to search for words not beginning with a single quote and with or without spaces
Multiple file output with JDK 6 XSLT implementation
HibernateTools Generating Wrong Code
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter