I'm trying to match:
<image=1,right>
- or -
<image=1>
where the 1 and 'right' become parameters.
So far I have:
preg_match_all('#<image=(.+?),(.+?)> | <image=([^>]+)#msi', $body,
$image_tags);
and
$image_count = preg_match_all('#<image=([^>]+)#msi', $body, $image_tags);
I'm trying to see if I can get them both into the one regexep, I assume
I have to use an alternative | somewhere, just not sure where.
Can anyone help? 4 1651
Logical wrote: I'm trying to match: <image=1,right> - or - <image=1>
where the 1 and 'right' become parameters.
So far I have: preg_match_all('#<image=(.+?),(.+?)> | <image=([^>]+)#msi', $body, $image_tags);
and
$image_count = preg_match_all('#<image=([^>]+)#msi', $body, $image_tags);
I'm trying to see if I can get them both into the one regexep, I assume I have to use an alternative | somewhere, just not sure where.
Can anyone help?
Of course I had to make a mistake in pasting my code.
That should have read:
preg_match_all('#<image=(.+?),(.+?)>#msi', $body, $image_tags);
and
preg_match_all('#<image=([^>]+)#msi', $body, $image_tags);
.oO(Logical) That should have read: preg_match_all('#<image=(.+?),(.+?)>#msi', $body, $image_tags); and preg_match_all('#<image=([^>]+)#msi', $body, $image_tags);
Try (untested)
preg_match_all('#<image=(.+)(,(.+))?>#isU', $body, $image_tags);
Micha
"Logical" <me@privacy.net> wrote in message
news:41***********************@un-2park-reader-01.sydney.pipenetworks.com.au... I'm trying to match: <image=1,right> - or - <image=1>
where the 1 and 'right' become parameters.
So far I have: preg_match_all('#<image=(.+?),(.+?)> | <image=([^>]+)#msi', $body, $image_tags);
and
$image_count = preg_match_all('#<image=([^>]+)#msi', $body, $image_tags);
I'm trying to see if I can get them both into the one regexep, I assume I have to use an alternative | somewhere, just not sure where.
Can anyone help?
I could be wrong, but wouldn't it be easier (or anyways take less processing
time) to do a str_replace()? Ex:
<?php
$params=explode( "|",
str_replace(
array( "<image=", ",", ">" ), array( "", "|", "" ), $body
)
);
print_r($params);
?>
- JP
"kingofkolt" <je**********@comcast.net> wrote in message
news:QL0%c.142335$mD.61186@attbi_s02... "Logical" <me@privacy.net> wrote in message
news:41***********************@un-2park-reader-01.sydney.pipenetworks.com.au... I'm trying to match: <image=1,right> - or - <image=1>
where the 1 and 'right' become parameters.
So far I have: preg_match_all('#<image=(.+?),(.+?)> | <image=([^>]+)#msi', $body, $image_tags);
and
$image_count = preg_match_all('#<image=([^>]+)#msi', $body,
$image_tags); I'm trying to see if I can get them both into the one regexep, I assume I have to use an alternative | somewhere, just not sure where.
Can anyone help?
I could be wrong, but wouldn't it be easier (or anyways take less
processing time) to do a str_replace()? Ex:
<?php $params=explode( "|", str_replace( array( "<image=", ",", ">" ), array( "", "|", "" ), $body ) );
print_r($params); ?>
- JP
My mistake. That logic would require that $body contains only the line
<image=1,right> and nothing else before or after the tag. Please ignore
me...
- JP This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: sinister |
last post by:
The examples in the online manual all seem to use double quotes, e.g. at
http://us3.php.net/preg_replace
Why? (The behavior is different with single quotes, and presumably simpler
to...
|
by: Margaret MacDonald |
last post by:
I'm trying to write a filter that will ignore text of the form
'\_foo\_' while filtering text of the form '_foo_'. In other words,
a backslash is meant to protect against the operation of this...
|
by: Juggernaut |
last post by:
Hi
I was trying to write a script to replace some text inside some tags.
Lets say I had <tag stuff=stuff><tag stuff=otherstuff><another>
I wanted it to find all the <tag and remove them.
So...
|
by: toedipper |
last post by:
Hello,
The following bit of code does a preg match and does something if true
(sets $browser to ppcie)
Without using if then and else's how do I code it so it does not equal
what it is...
|
by: system7designs |
last post by:
I don't know preg's that well, can anyone tell me how to write a
regular expression that will select everything BUT files/folders that
begin with ._ or __?(that's period-underscore and underscore...
|
by: frizzle |
last post by:
Hi group,
I have a function which validates a string using preg match.
A part looks like
if( !preg_match( '/^(+((*)?)?)$/', $string )
||
preg_match( '/(--|__)+/' ,$string) ) {
i wonder...
|
by: terence.parker |
last post by:
I am trying to do a search through some data, more specifically HTML,
to extract data from it. So for example I may have:
<b>Title:</b<em>This is a title</em>
<b>Name:</b<em>Fred</em>
I wish...
|
by: monomaniac21 |
last post by:
hi all
what is the preg for capitals in a word to be replaced by that word
preceded by a space?
i need to be able to do this in preg:
thisWord := this Word
AnotherExample := Another Example
|
by: moishy |
last post by:
If I wanted to match for instance, all characters that are not in <TAGS>, I would search for all ">ANYTHING<".
But how do I make that "ANYTHING"?
What will be the PREG for absolutely ANY...
|
by: JanDoggen |
last post by:
function vldLicense($lic)
{
echo "called with lic: ". $lic . "<br>";
echo preg_match('', $lic) . "<br>";
if (preg_match('{4}-{4}-{4}-{4}', $lic) == 0) return false;
return true;
}
gives me:
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |