/    Sign up×
Community /Pin to ProfileBookmark

regex simple problem

hi,

I’m using preg_replace like this

preg_replace($urlin, $urlout, $content);

and the arrays are like this :

$urlin = array(
“‘(?<!/)index.php?name=([0-9a-zA-Z]+)&act=([0-9a-zA-Z-|]+)&act2=([0-9a-zA-Z-_. `[]]+)'”,
.
.
);

$urlout = array(
http://www.example.com/1/2/3/“,
.
.
.

instead of [0-9a-zA-Z-|] in the urlin array, i wanna make it with all characters (before i only needed letters and numbers, but now I need all possible characters),
I’ve tried something like this, But it doesn’t seem to work :
$urlin = array(
“‘(?<!/)index.php?name=(.+)&act=(.+)&act2=(.+)'”,

what should I use for it to take effect?
Thanks

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@MindzaiJan 11.2009 — (?&lt;!/)</URL>

I think this may be your problem. ? means 0 or 1 of the preceding character, but you don't specify a preceding character. When I remove that part of the regex it matches the following as expected:

http://www.sample.com/index.php?name=foo!39&amp;act=bar#2&amp;act2=1231
Copy linkTweet thisAlerts:
@NogDogJan 11.2009 — [b](?<!/)[/b] would be a negative look-behind assertion on the "/" character, so may be valid depending on what is actually wanted, functionally.

Anyway, if the text being matched by the [b].+[/b] could include newlines, you'll need to add the "s" modifier after the closing regexp delimiter.
×

Success!

Help @asmith20002 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...