Jump to content
Sign in to follow this  
EvAsion

StringRegExpReplace query.

Recommended Posts

EvAsion

OK, i have a string like this 'H24O18C19'

How can i put a comma between 'the end of a series of numbers' and a letter

so: 'H24,O18,C19'

i was thinking something like this.

$string = "H24O18C19"
$replace = StringRegExpReplace($string, "\d(\w)*?",",")
msgbox(0,"",$replace)

Edit: see bottom post.

Edited by EvAsion

Share this post


Link to post
Share on other sites
SmOke_N

$string = "H24O18C19"
$replace = StringRegExpReplace($string, "\w\d+","\0,")
msgbox(0,"",StringTrimRight($replace, 1))


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
EvAsion

Oh and one more thing If i have 2 capital letters next to each other, or a noncapital next to a capital, how can i put a 1 between them(or if i have a capital letter then white space or nothing, put a 1 after the capital letter)? So 'HeHP' becomes 'He1H1P1'

How can i put a , in a string like 'He232' between the end of the letters and the start of the numbers (becoming 'He,232'), regardless of how many letters/numbers there are on each side?

Edited by EvAsion

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×