Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Need to split and exclude a string - PHP
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Rus Miller  
View profile  
 More options Jun 20, 5:20 pm
From: Rus Miller <lancemonot...@gmail.com>
Date: Sat, 20 Jun 2009 14:20:53 -0700 (PDT)
Local: Sat, Jun 20 2009 5:20 pm
Subject: Need to split and exclude a string - PHP
The pattern of the string will be something like the following:

60003 Lichen<br />Stripe<br />

What I need to do is exclude everything after the product name (in
this case, 'Lichen').  The resulting string should look like:

60003 Lichen

Thank you for your help!


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eugeny Sattler  
View profile  
 More options Jun 22, 3:25 am
From: Eugeny Sattler <eugeny.satt...@gmail.com>
Date: Mon, 22 Jun 2009 12:25:19 +0500
Local: Mon, Jun 22 2009 3:25 am
Subject: Re: Need to split and exclude a string - PHP
Firstly,  you most probably meant </br> and not <br/>
60003 Lichen</br>Stripe</br>

Secondly, lets define approach: you mean the necessary info ends right
in front of the first "</br>", right?

in this case the regex will be
^.*?(?=\<\/br\>)

and, if applied to my reply text,  three matching results will be:

"First you probably mean "
"60003 Lichen"
"Secondly, lets define approach: you mean the necessary info ends
right in front of the first ""

A bit of explanation:
^ checks if we are at the start of a line but grabs nothing (it is an anchor)
.*? is a lazy dot, i.e. it grabs anything as few times as possible, so
that the next regex construct finds its match
and finally (?=\<\/br\>) again grabs nothing but checks whether what
we have to the right is "</br>"
Putting a backslash in front of special; symbols is a precaution in
order that they are not treated as special symbols of programming
language/environment

--
Regards,
Eugeny Sattler


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rus Miller  
View profile  
 More options Jun 22, 9:42 am
From: Rus Miller <lancemonot...@gmail.com>
Date: Mon, 22 Jun 2009 06:42:14 -0700 (PDT)
Local: Mon, Jun 22 2009 9:42 am
Subject: Re: Need to split and exclude a string - PHP
Thanks for the reply and the explanation. Your solution does work,
although I did mean <br />, which is valid XHTML for self-closing
elements.

http://www.w3schools.com/TAGS/tag_br.asp

On Jun 22, 3:25 am, Eugeny Sattler <eugeny.satt...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google