only letters

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
bimo
Forum Contributor
Posts: 100
Joined: Fri Apr 16, 2004 11:18 pm
Location: MD

only letters

Post by bimo »

would this be the correct regex way to say, "pick all the characters until a number is come across"?

Code: Select all

(^.*\D)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

not really...

Code: Select all

#^(ї^\d]*)#
this is for a preg_* function...
User avatar
bimo
Forum Contributor
Posts: 100
Joined: Fri Apr 16, 2004 11:18 pm
Location: MD

Post by bimo »

I'm so sorry... I didn't mean to ask that b/c it seems to be working for me. I will try your way too. what I meant to ask was this:

I want to pick out the nth and nth +1 character out after I extract the letters off of the beginning of a string. In other words, after I pick out the letters at the beginning of a string there are 6 numbers. I want to pick out the 1st and scond, 3rd and 4th or 5th and 6th.

I thought about cycling through the string's character array like you can do in C++ but wasn't sure if that was a great idea since the length of the word is indeterminate.

can I cycle through the string backwards (the six digits are always going to be the last six)

your help is much appreciated
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

substr($string,-6)
will fetch the last 6 characters in the string.
User avatar
bimo
Forum Contributor
Posts: 100
Joined: Fri Apr 16, 2004 11:18 pm
Location: MD

Post by bimo »

Thank you, feyd.
Post Reply