So, thinking about it a little more, I decided what I was looking for was
a
regular expression that would allow me to replace any incidences of
hyphens
when not contained within tags (i.e., when not contained between and
).
And this is where things have ground to a halt.
Hi All,
After
On Monday 16 May 2005 22:53, Al wrote:
What pattern can I use to match ONLY single occurrences of a character in a
string.
e.g., Some text @ and some mo@@re and [EMAIL PROTECTED], etc @@@.
Use the following:
/(^@)(@{1})(^@)/
This way you'll be sure the regexp will match only single
Murry's solution here is ideal since it only captures the single occurrence.
Since I want to use it for a preg_replace(), it is perfect.
A couple of folks sent this pattern [EMAIL PROTECTED]@[EMAIL PROTECTED]; but, it doesn't work because I
then have to remove the unwanted caracters on either
Try (for example if character was A) ...
([^A]|^)A([^A]|$)
This matches four cases:
A is at beginning of string and there is another letter after it,
A has a letter before it and a letter after it,
A is at end of string and there is a letter before it,
or A is the only character in the string.
On Mon, 16 May 2005, Al wrote:
What pattern can I use to match ONLY single occurrences of a character in a
string.
e.g., Some text @ and some mo@@re and [EMAIL PROTECTED], etc @@@.
I only want the two occurrences with a single occurrence of @.
[EMAIL PROTECTED]@[EMAIL PROTECTED]
should do it I
What pattern can I use to match ONLY single occurrences of a character in
a string.
e.g., Some text @ and some mo@@re and [EMAIL PROTECTED], etc @@@.
I only want the two occurrences with a single occurrence of @.
@{1} doesn't work; there are 4 matches.
/[EMAIL PROTECTED]@[EMAIL
What pattern can I use to match ONLY single occurrences of a character in
a string.
e.g., Some text @ and some mo@@re and [EMAIL PROTECTED], etc @@@.
I only want the two occurrences with a single occurrence of @.
@{1} doesn't work; there are 4 matches.
Thanks
Please ignore my
Try (for example if character was A) ...
([^A]|^)A([^A]|$)
This matches four cases:
A is at beginning of string and there is another letter after it,
A has a letter before it and a letter after it,
A is at end of string and there is a letter before it,
or A is the only character in the
?php
$text = 'Some text @ and some mo@@re and [EMAIL PROTECTED], etc @@@.';
/** Word boundaries before and after @ */
$regex = '/[EMAIL PROTECTED]/';
preg_match_all($regex, $text, $matches);
var_dump($matches);
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit:
On 17-Jun-2003 Ron Dyck wrote:
I need to match text between two html comment tags.
I'm using: preg_match(/!--start_tag--(.*)!--end_tag--/, $data,
$Match)
Which work fine until I have carriage returns. The following doesn't
match:
Use the m (multiline) modifier:
Hello
Two things:
First wouldn't it be faster to use strpos and substr if you simply have to
find the literate !-- start_tag -- and !-- end_tag --.
Second: If you use your regex and you have something like
!-- start_tag -- This is some text to grasp!-- end_tag -- this is
text I don't want !--
. matches any character except newline by default, use s modifier:
preg_match(/!--start_tag--(.*)!--end_tag--/s, $data, $Match)
Ron Dyck wrote:
I need to match text between two html comment tags.
I'm using: preg_match(/!--start_tag--(.*)!--end_tag--/, $data, $Match)
Which work fine until I have
Troy May wrote:
How would take a regular non-formatted text link (http://www.link.com) and
turn it into ready to post HTML? (a
href=http://www.link.comhttp://www.link.com/a)
Darn, Outlook formats it, but you get the idea. It would just be typed out
normally.
Any ideas?
function MakeUrl
Hello,
Leif K-Brooks [EMAIL PROTECTED] wrote:
[snip]
But that doesn't work at all. Any ideas on how to do this?
[/snip]
Would't it be easier (and faster) to use
http://www.php.net/manual/en/function.str-replace.php ?
- E
--
PHP General Mailing List (http://www.php.net/)
To
I need to do a few other things that require regex though, like making
either an a or an @ match (people love to get around filters by using
symbols instead of letters...).
@ Edwin wrote:
Hello,
Leif K-Brooks [EMAIL PROTECTED] wrote:
[snip]
But that doesn't work at all. Any ideas on how
Actually for a job like this look to substr() to extract the last three
chars as a string and compare them in an if() statment.
http://www.php.net/manual/en/function.substr.php
-Kevin
- Original Message -
From: David Busby [EMAIL PROTECTED]
To: php-general [EMAIL PROTECTED]
Sent:
$string = 'somethingphp';
$pat = 'php$';
$hasphp = ereg($pat, $string);
Henning Sittler
www.inscriber.com
-Original Message-
From: David Busby [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 02, 2002 4:49 PM
To: php-general
Subject: [PHP] RegEx question
List,
How can I
eregi(php$, $stringtobecompared);
See: http://www.php.net/manual/en/ref.regex.php
Gurhan
- Original Message -
From: David Busby [EMAIL PROTECTED]
To: php-general [EMAIL PROTECTED]
Sent: Tuesday, July 02, 2002 4:49 PM
Subject: [PHP] RegEx question
List,
How can I regex to compare
Hi all,
I've got a regex that's working fine, apart from one little problem.
$tags = array (script,
!--!\[CDATA\[,
\]\]--);
A quick shot (perhaps I miss the point ;): if you do
$x = \[;
then $x will contain [. If you then do a regex with preg_match(/$x/,
...
If you want the [ to be escaped in the regex you have to double-escape
it:
$x = \ \[; (sorry, the two \ should be together without a space but my
stupid mail-app converts the string thinking it's an network address)
so $x will contain \[ as you want ( the first backslash escapes the
second).
If you want the [ to be escaped in the regex you have to double-escape
it:
$x = \ \[; (sorry, the two \ should be together without a space but my
stupid mail-app converts the string thinking it's an network address)
so $x will contain \[ as you want ( the first backslash escapes the
As far as I can see (notice: I'm not a regex-king ;) the regex seems
correct
to me. The only thing I'm wondering about is the /^ (second last line
of
the citation). Together with your expression in the array it results in
preg_match(/\/!\[CDATA\[/, ...)
I'm wondering if that (/![CDATA...) is
In case anyone is interested, eregi(HTTP/1.[01].302,$output) seems to
work :)
berber
-Original Message-
From: Boaz Yahav
Sent: Tuesday, July 31, 2001 2:03 PM
To: PHP General (E-mail)
Subject: [PHP] Regex question
I'm trying to find if a string exists inside a string. Instead of using
if (preg_match_all(|testing(.*?);blah|s, $str, $matches))
{
// do what you want with $matches: see in the manual!
var_dump($matches);
}
- Original Message -
From: George E. Papadakis [EMAIL PROTECTED]
To: PHP List [EMAIL PROTECTED]
Sent: 2001. május 20. 19:18
Subject: [PHP] RegEx
On Sunday 20 May 2001 19:18, George E. Papadakis wrote:
I have an ereg question::.
$data = a big string ,
while (ereg (testing([^;]*);blah(.*),$data,$args)) {
$this = $args[1];
$data = $args[2];
}
What I wanna do ,obviously, is to get all the strings between 'testng'
and 'blah'
25 matches
Mail list logo