You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Ninju Bohra <ni...@yahoo.com> on 2005/06/22 22:54:37 UTC

Need help writing regular expression??

Hello all,

Quick question... I need write a regular expression to
generate <FirstLetterOfFirstName><LastName> from a
full name (i.e. <First Name> <Last Name>)

Given the string:  Ninju Bohra

I want:  NBohra

What is the regular expression (if any) I would use?

<property name="full.name" value="Ninju Bohra"/>

<propertyregex property="userID"
              input="${full.name}"
              regexp="<need help here>"
              select="\1"
              casesensitive="false" />
    
Thanx,

Ninju





		
____________________________________________________ 
Yahoo! Sports 
Rekindle the Rivalries. Sign up for Fantasy Football 
http://football.fantasysports.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Need help writing regular expression??

Posted by "Alexey N. Solofnenko" <A....@mdl.com>.
I would try to replace all spaces '\s' with empty values.

- Alexey.

Ninju Bohra wrote:
> Hello all,
>
> Quick question... I need write a regular expression to
> generate <FirstLetterOfFirstName><LastName> from a
> full name (i.e. <First Name> <Last Name>)
>
> Given the string:  Ninju Bohra
>
> I want:  NBohra
>
> What is the regular expression (if any) I would use?
>
> <property name="full.name" value="Ninju Bohra"/>
>
> <propertyregex property="userID"
>               input="${full.name}"
>               regexp="<need help here>"
>               select="\1"
>               casesensitive="false" />
>     
> Thanx,
>
> Ninju
>
>
>
>
>
> 		
> ____________________________________________________ 
> Yahoo! Sports 
> Rekindle the Rivalries. Sign up for Fantasy Football 
> http://football.fantasysports.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>   

-- 
------------------------------------------------------------------------
/ Alexey N. Solofnenko
home: http://trelony.cjb.net/
/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


RE: Need help writing regular expression??

Posted by Bill Rich <br...@webmethods.com>.
<propertyregex property="userID"
              input="${full.name}"
              regexp="(.)[^\s]*\s([^\s]*)\s"
              select="\1\2"
              casesensitive="false" />

You may have to play around with it to make sure the whitespaces are in the
right places, especially the end of the line. I assumed that a name was on a
single line terminated by whitespace. You are also assuming that a person
can have only two parts to their name. If the last name can have Jr., III,
or something like that following it this reg exp will truncate the name. So,
Fred Flintstone II will be FFlintstone and you will loose that fact that he
has a different name than his father, Fred Flintstone.

HTH Bill
-----Original Message-----
From: Ninju Bohra [mailto:ninju_bohra@yahoo.com] 
Sent: Wednesday, June 22, 2005 1:55 PM
To: Ant Users Group
Subject: Need help writing regular expression??

Hello all,

Quick question... I need write a regular expression to generate
<FirstLetterOfFirstName><LastName> from a full name (i.e. <First Name> <Last
Name>)

Given the string:  Ninju Bohra

I want:  NBohra

What is the regular expression (if any) I would use?

<property name="full.name" value="Ninju Bohra"/>

<propertyregex property="userID"
              input="${full.name}"
              regexp="<need help here>"
              select="\1"
              casesensitive="false" />
    
Thanx,

Ninju





		
____________________________________________________
Yahoo! Sports
Rekindle the Rivalries. Sign up for Fantasy Football
http://football.fantasysports.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional
commands, e-mail: user-help@ant.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org