case conversion in regexp subexpression 
Author Message
 case conversion in regexp subexpression

Hi all,

i searched a lot but didn't find any hint how to solve the following
issue:
I'm looking for a regular expression that produces a subexpression
with the first character uppercase no matter the case was in die
matched sample.
E.g.

getCustomer --regexp--> Customer
getcustomer --regexp--> Customer
getxyz      --regexp--> Xyz

What i have found so far is the simple get(.*) but that doesn't
uppercase the first character.

I'm using gnu.regexp regular expressions for java so i cannot deal
with perl operations.

Any help would be greatly appreciated. Thanks



Mon, 17 May 2004 09:49:59 GMT  
 case conversion in regexp subexpression

Quote:
> Hi all,

> i searched a lot but didn't find any hint how to solve the following
> issue:
> I'm looking for a regular expression that produces a subexpression
> with the first character uppercase no matter the case was in die
> matched sample.
> E.g.

> getCustomer --regexp--> Customer
> getcustomer --regexp--> Customer
> getxyz      --regexp--> Xyz

> What i have found so far is the simple get(.*) but that doesn't
> uppercase the first character.

my $string = 'getcustomer';
$string =~ s/get(.*)/\u$1/;

Cheers,
Bernard



Mon, 17 May 2004 10:13:46 GMT  
 case conversion in regexp subexpression

Quote:
> Hi all,

> i searched a lot but didn't find any hint how to solve the following
> issue:
> I'm looking for a regular expression that produces a subexpression
> with the first character uppercase no matter the case was in die
> matched sample.
> E.g.

> getCustomer --regexp--> Customer
> getcustomer --regexp--> Customer
> getxyz      --regexp--> Xyz

> What i have found so far is the simple get(.*) but that doesn't
> uppercase the first character.

> I'm using gnu.regexp regular expressions for java so i cannot deal
> with perl operations.

Despite your cross-post, your inquiry is not strictly on-topic in any of the
newsgroups.

Parenthetically, congratulations on breaking new conceptual ground and
thinking something would be on-topic in both Perl and Java newsgroups at the
same time.

http://www.google.com/search?hl=en&q=regexp+tutorial

--
Paul Lutus
www.arachnoid.com



Mon, 17 May 2004 21:01:02 GMT  
 case conversion in regexp subexpression

Quote:



> > Hi all,

> > i searched a lot but didn't find any hint how to solve the following
> > issue:
> > I'm looking for a regular expression that produces a subexpression
> > with the first character uppercase no matter the case was in die
> > matched sample.
> > E.g.

> > getCustomer --regexp--> Customer
> > getcustomer --regexp--> Customer
> > getxyz      --regexp--> Xyz

> > What i have found so far is the simple get(.*) but that doesn't
> > uppercase the first character.

Is there any reason not to do the uppercase transformation as a String
or StringBuffer operation after the regular expression has done the
extraction? Note that Character has a static toUpperCase method.

Quote:

> > I'm using gnu.regexp regular expressions for java so i cannot deal
> > with perl operations.

> Despite your cross-post, your inquiry is not strictly on-topic in any of the
> newsgroups.

Huh? The inquiry is about the use of a "regular expressions for java"
package. That seems like a matter of Java programming and a request for
help with Java.

Given the stated inability to use Perl, I'm changing the follow-ups to
delete comp.lang.perl.misc

Patricia



Tue, 18 May 2004 03:52:01 GMT  
 case conversion in regexp subexpression

Quote:


> > I'm looking for a regular expression that produces a subexpression
> > with the first character uppercase no matter the case was in die
> > matched sample.
> > E.g.

> > getCustomer --regexp--> Customer
> > getcustomer --regexp--> Customer
> > getxyz      --regexp--> Xyz

> > What i have found so far is the simple get(.*) but that doesn't
> > uppercase the first character.

> my $string = 'getcustomer';
> $string =~ s/get(.*)/\u$1/;

Thank You. Anyway this it exactly what i could have expected posting
this question to perl.misc: ** I am not able to use s/// ** so i am
not able to modify the $1 value _after_ its evaluation. I need need $1
to equal "Customer" directly.
Is this possible?


Tue, 18 May 2004 08:55:57 GMT  
 case conversion in regexp subexpression

Quote:


>> > I'm looking for a regular expression that produces a subexpression
>> > with the first character uppercase no matter the case was in die
>> > matched sample.
>> > E.g.

>> > getCustomer --regexp--> Customer
>> > getcustomer --regexp--> Customer
>> > getxyz      --regexp--> Xyz

>> > What i have found so far is the simple get(.*) but that doesn't
>> > uppercase the first character.

>> my $string = 'getcustomer';
>> $string =~ s/get(.*)/\u$1/;

> Thank You. Anyway this it exactly what i could have expected posting
> this question to perl.misc:

Well excuuuuuuuuuse me.

Quote:
> ** I am not able to use s/// ** so i am
> not able to modify the $1 value _after_ its evaluation. I need need $1
> to equal "Customer" directly.
> Is this possible?

I didn't read your OP carefully enough. Had I done so I would have
ignored it since it's obviously off-topic here.

Cheers,
Bernard



Tue, 18 May 2004 10:53:55 GMT  
 case conversion in regexp subexpression

Quote:

>I'm looking for a regular expression that produces a subexpression
>with the first character uppercase no matter the case was in die
>matched sample.
>E.g.

>getCustomer --regexp--> Customer
>getcustomer --regexp--> Customer
>getxyz      --regexp--> Xyz

>What i have found so far is the simple get(.*) but that doesn't
>uppercase the first character.

Perl has the ucfirst() and lcase() builtin functions, but you can't use
that in Java. No you can't do it with a regex alone, since what it
matched is literally what it matched.

--
        Bart.



Tue, 18 May 2004 13:59:12 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Intelligent case conversion? (eg., Title Case)

2. perl5 case conversion

3. help wanted: case conversion off word boundary

4. case conversion

5. Conversion to upper case

6. Case Conversion

7. Upper to Lower case Conversion

8. Need help with upper/lower case conversion

9. String case conversion in Perl

10. lower/upper case conversion

11. Find case conversion script for filenames

12. Strange behaviour in upper case conversion

 

 
Powered by phpBB® Forum Software