|
sandeep_war@rediffmail.com - 29 Aug 2008
I have an expression
((( 5339) * ( 1 + Cess Duty + 0.14 * ( 1 + 0.02 + 0.01) + Packing & Forwarding) + Packing & Forwarding fixed))
In the above expression the value to be replaced is coming from sql query in which "Packing & Forwarding" is coming before "Packing & Forwarding fixed". When i use replace function both "Packing & Forwarding" gets replaced and in second place only "0 fixed" remains. How to replace this value.
Anybody can help me.....
Thanks in advance
Sandeep
amateur - 29 Aug 2008
Excellent! But I dont fully understand the use of the () brackets. =/
amateur - 29 Aug 2008
Excellent! But I dont fully understand the use of the () brackets. =/
A PHP User - 29 Aug 2008
can someone explain me what this expression does exactly
Set your own pattern of preg_replace function.Default: /[,.\-:><()!?\n]/
in case of problems try this: /[^a-zA-Z0-9\200-\377]/
Hmmm - 29 Aug 2008
I want to do this - whenever I get a filename stored in a variable (f.e. $file1), I want to remove all dots from this variable, EXCEPT if they are in last four or five spots (so I dont delete file extension.
Hmmm - 29 Aug 2008
I want to do this - whenever I get a filename stored in a variable (f.e. $file1), I want to remove all dots from this variable, EXCEPT if they are in last four or five spots (so I dont delete file extension.
Hmmm - 29 Aug 2008
I want to do this - whenever I get a filename stored in a variable (f.e. $file1), I want to remove all dots from this variable, EXCEPT if they are in last four or five spots (so I dont delete file extension.
A PHP User - 29 Aug 2008
This page has helped a ton! ...however it doesn't really address () operations...
jmoliveira at ulusofona dot pt - 29 Aug 2008
I'm a newbie (i know more chinese than regexp) but i solved my problem. If it is of any good to any other user, here is the code:
function auto_link($foo) {
$foo = preg_replace('/(?<!\S)([A-Z_\-\w-.]+)(@)([A-Z_\-\w-.]+)\b/i', '<a href="mailto:$1@$3">$1@$3</a>', $foo);
$foo = preg_replace('/(?<!\S)((http(s?):\/\/)|(www\.))+([\w.\/&=?\-~%;]+)\b/i', '<a href="http$3://$4$5" target="_blank">http$3://$4$5</a>', $foo);
$foo = preg_replace('/(?<!\S)((ftp(7?):\/\/)|(ftp\.))([\w.\/&=?\-~%;]+)\b/i', '<a href="ftp$3://$4$5" target="_blank">ftp$3://$4$5</a>', $foo);
return ($foo);
}
I hope my code ain't that bad at all.
Best Regards
jmoliveira at ulusofona dot pt - 29 Aug 2008
message to d at aerno dot com
Hey man, could you help me? your script is the best I found on the web to create auto links from url's and e-mails. Although I have an e-mail with an hyphen (-) and the replace ends there, someting link this:
abc@be-f.gh => abd@be
what can I do to repair this? I'm trying to understand the syntax of regexp but it is going to take a while and my time is running out.
Many thanks in advance
jmoliveira at ulusofona dot pt - 29 Aug 2008
message to d at aerno dot com
Hey man, could you help me? your script is the best I found on the web to create auto links from url's and e-mails. Although I have an e-mail with an hyphen (-) and the replace ends there, someting link this:
abc@be-f.gh => abd@be
what can I do to repair this? I'm trying to understand the syntax of regexp but it is going to take a while and my time is running out.
Many thanks in advance
A |\| 3 \/\/ 13 | E PHP User - 29 Aug 2008
My brain hurts :-\
d at aerno dot com - 29 Aug 2008
This is for the person who wished to see a more practical example of hyperlinking an email address or URL.
function autolink($foo) {
$foo = preg_replace('/(?<!\S)([\w.]+)(@)([\w.]+)\b/i', '<a href="mailto:$1@$3">$1@$3</a>', $foo);
$foo = preg_replace('/(?<!\S)((http(s?):\/\/)|(www\.))+([\w.\/&=?\-~%;]+)\b/i', '<a href="http$3://$4$5" target="_blank">http$3://$4$5</a>', $foo);
$foo = preg_replace('/(?<!\S)((ftp(7?):\/\/)|(ftp\.))([\w.\/&=?\-~%;]+)\b/i', '<a href="ftp$3://$4$5" target="_blank">ftp$3://$4$5</a>', $foo);
return ($foo);
}
Guna - 29 Aug 2008
Compared to other manuals, I have read this manual explains Simply and in detail. This gives a better understanding of Regular Expression usuage.
I would be more useful, if u give real time examples(extracting emailids, links,etc.,)
foobar - 29 Aug 2008
I had lot of confusions regarding regexp before reading this session. It really helped me. Thanks.
A PHP User - 29 Aug 2008
[A-Z]{1,3}
3 uppercase letters
You must mean 1 to 3 uppercase letters
Dirk - 29 Aug 2008
Nice, but you forget the "|" ( OR ):
if (preg_match("/(php|asp)/", "asp")) {
print "Got it!";
}
matches for "php" OR "asp".
A PHP User - 29 Aug 2008
This site has really helped me to learn some PHP. Thank you!
Add comment
Please note that by posting a comment here you are committing it to the public domain. This is important so that others can make use of your code themselves, and also so that I can incorporate helpful notes directly into the main text. Comments are limited to 2000 characters in length.
If you are reporting an error in the content, please tell me directly.
|