Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
What is the php regular expression to get everything before a certain character?
Old 07-14-2009, 04:57 AM What is the php regular expression to get everything before a certain character?
Novice Talker

Posts: 9
Name: Gary
Trades: 0
For instance, I have the following string:

table:column

I need to get "table" as the result of the php regular expression.

So, I need everything before the ":" symbol

After that regular expression is performed, I would also like to get everything after the ":" symbol, or "column" as well.
AHCAROS is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-14-2009, 09:41 AM Re: What is the php regular expression to get everything before a certain character?
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
For something this simple, you may have better handeling using the explode/split method.

PHP Code:
$string 'table:column';
 
$value explode(':'$string);
 
$table $value[0];
$column $value[1]; 
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 07-14-2009, 10:08 AM Re: What is the php regular expression to get everything before a certain character?
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Exactly. Exploding is a key tool, and should be memorized by every PHP developer. Every language I've worked with has an equivalent. For example, JavaScript has arrayObject = stringObject.split(":");
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is online now
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Reply     « Reply to What is the php regular expression to get everything before a certain character?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.47411 seconds with 12 queries