Regular expression needed

Started on the old forum in September 2010 · view the original in the archive · old links redirect here

8 replies · 511 views · started 16 years ago · 1 min read

5 participants
antony2kx Developer · 94 posts #3

thanks for trying but thats not what am taking about, i am talking removing the the value of the attributes from the element

so if i have value2

i want to get value1 and value2 from the string using some preg_match or some preg_replace its the regular expression that i dont knw

Mysterio Lead · 630 posts #4

$value1 = explode(""", $all_html_here); $value1 = $value1[1];

Like this?

mysterio.al - programming is a functional art

mob_mate Junior · 18 posts #5

$General_value = array("value_1,"value_2"); $Call_value = rand(0,count($General_value)-1); include($General_value[$Call_value]);

like this simple value call? .... Hmm I cant get u mate or u mean what?

GumSlone Administrator Principal · 1,690 posts #6
$s = "<a href='value1'>value2</a>";
preg_match("/<a href=[\"|'](.*)[\"|']>(.*)<\/a>/i", $s, $m);
print_r($m);

output will be:

Array
(
    [0] => <a href='value1'>value2</a>
    [1] => value1
    [2] => value2
)

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

antony2kx Developer · 94 posts #7

thank you very much gumslone, that is what i am looking for, thanks alot

Added after 44 minutes:

<?php
echo '<br/> link';

$s = '<a href="value1">value2</a>';
preg_match("/<a href=[\"|'](.*)[\"|']>(.*)<\/a>/i", $s, $m);
print_r($m);

echo '<br/> image';

$image = '<img src="value1" alt="value2"/>';

preg_match("/<img src=[\"|'](.*)[\"|] alt=[\"|'](.*)[\"|']\/>/i", $image, $t);

print_r($t);

echo '<br/> image link';

$imagelink = '<a href="link"><img src="image source" alt="image title"/></a>';

preg_match("/<a href=[\"|'](.*)[\"|']><img src=[\"|'](.*)[\"|] alt=[\"|'](.*)[\"|']\/><\/a>/i", $imagelink, $v);

print_r($v);

?>
mob_mate Junior · 18 posts #8

What abt other commenter?

Mysterio Lead · 630 posts #9

mob_mate wrote: What abt other commenter?

There are some users here, who made half questions, then let us guess what the question is and find a right answer. But how?

mysterio.al - programming is a functional art

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close