|
[Date Index]
[Thread Index]
[Author Index]
Operations on RegularExpression matches
- To: mathgroup at smc.vnet.net
- Subject: [mg119991] Operations on RegularExpression matches
- From: Jon Joseph <josco.jon at gmail.com>
- Date: Mon, 4 Jul 2011 06:44:57 -0400 (EDT)
All:
I have string of all lower case letters:
string = "this is a string"
I wish to capitalize the first letter:
StringReplace[string, StartOfString ~~ x_ -> ToUpperCase[x]] (* Does want I want *)
Now I try to do the same thing using RegularExpression:
StringReplace[string, RegularExpression["(^.)"] -> ToUpperCase["$1"]]
which fails (returns original string without capitalization).
I know the match is occurring since
StringReplace[string, RegularExpression["(^.)"] -> ToUpperCase["$1X"]]
returns
"tXhis is a string"
What am I missing about using the matched part of a regular expression?
Thanks.
Prev by Date:
Re: Font and Style problems using Image to create bitmaps of Plots/Charts etc
Next by Date:
Numerical accuracy/precision - this is a bug or a feature?
Previous by thread:
Re: Insoluble marbles-in-urn problem?
Next by thread:
Re: Operations on RegularExpression matches
|