Gossamer Forum
Home : General : Perl Programming :

Practice makes perfect, or not :p

Quote Reply
Practice makes perfect, or not :p
I've been playing with this for a while...but I just can't seem to get it to work. I'm trying to get some regex that will do the following;

change someThing to some Thing (i.e put a space before the capital letter), and also;

change 'sword to 's word ... i.e a space after the 's and the next word.

Trust me, there is a good reason to be wanting to do this Tongue

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Practice makes perfect, or not :p In reply to
Pretty simple...

Code:
$string =~ s/([A-Z])/ $1/g;

...and...

Code:
$string =~ s/'s/'s /g;
Quote Reply
Re: [Paul] Practice makes perfect, or not :p In reply to
Thanks. Won't the second one change things like;

's hello

to

's hello

i.e with 2 spaces?

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Paul] Practice makes perfect, or not :p In reply to
Code:
$string =~ s/'s([a-z])/'s $1/g;
Quote Reply
Re: [Andy] Practice makes perfect, or not :p In reply to
The first one also does stuff like changing;

LONDON to L O N D O N, and NATO to N A T O Unsure

Is there anyway around this?

Thanks for the help so far Smile

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Paul] Practice makes perfect, or not :p In reply to
In Reply To:
Code:
$string =~ s/'s([a-z])/'s $1/g;
Didn't work Unsure

What I may do, is something like;

$string =~ s/'s/'s /g;
$string =~ s/ / /g;

i.e do your regex stuff, and then replace the double spaces with single ones.

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Practice makes perfect, or not :p In reply to
Quote:
The first one also does stuff like changing;

LONDON to L O N D O N, and NATO to N A T O

Well you said you wanted to put a space before capital letters.

Quote:
Didn't work

Seems ok for me.
Quote Reply
Re: [Paul] Practice makes perfect, or not :p In reply to
I have the thing like;

theWord

...working with;

$wanted =~ s/([a-z])([A-Z])/$1 $2/g;

So things like 'theWord' is changed to 'the Word'.

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates