Jump to content

Preg Replace


RobertP

Recommended Posts

i am in need of a regular expression that will parse my associative array keys into clean strings.

 

example:

testKeyString33 = Test Key String 33
dbHost = Db Host
simpleStringWithMore = Simple String With More

 

This is how i think it would work...

- append a space to all UPPER CASE letters (aSd = a Sd)

- append a space to the start of all integers... (asd123 = asd 123)

 

if this is confusing at all, please say so :S

Link to comment
Share on other sites

no, it's a negative look-behind.  It checks to see if the character it is looking for isn't at the start of the string, by looking at the character that comes before it (the ^ signifies start of string, which isn't an actual character, but you get the idea).  Otherwise, you will end up with for instance "Abc" to " Abc"

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.