Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #3486
| From | Patrick Scheibe <pscheibe@trm.uni-leipzig.de> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Operations on RegularExpression matches |
| Date | 2011-07-05 09:16 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <iuukq0$equ$1@smc.vnet.net> (permalink) |
| References | <201107041044.GAA02505@smc.vnet.net> |
Hi, do you know the difference between Rule (->) and RuleDelayed(:>)? Cheers Patrick On Mon, 2011-07-04 at 06:44 -0400, Jon Joseph wrote: > 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. >
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: Operations on RegularExpression matches Patrick Scheibe <pscheibe@trm.uni-leipzig.de> - 2011-07-05 09:16 +0000
csiph-web