I have a line like this in some PHP code on my Web page:
$callthis =~ s/<[^>]*>//g;
When the page runs, I get this error:
Parse error: parse error, unexpected '<' in /Feedback.php on line 145
So I presume I must escape angle brackets somehow in the regular
expression. How do I do it? I tried putting a backslash in front of
each angle bracket, but that doesn't seem to work (same error).
The purpose of the statement is to remove HTML tags from the string.
--
Transpose hotmail and mxsmanic in my e-mail address to reach me directly. 7 6658
Mxsmanic wrote: I have a line like this in some PHP code on my Web page:
$callthis =~ s/<[^>]*>//g;
When the page runs, I get this error:
Parse error: parse error, unexpected '<' in /Feedback.php on line 145
That doesn't look like any PHP code that I know.
Use the function strip_tags() to strip HTML from strings.
Ken
Mxsmanic wrote: I have a line like this in some PHP code on my Web page:
$callthis =~ s/<[^>]*>//g;
Looks like Perl to me.
When the page runs, I get this error:
Parse error: parse error, unexpected '<' in /Feedback.php on line 145
So I presume I must escape angle brackets somehow in the regular expression. How do I do it?
With a \ but I doubt that's the problem.
I tried putting a backslash in front of each angle bracket, but that doesn't seem to work (same error).
That's because it's not PHP.
Try this: $callthis = preg_replace("/<[^>]*>/", "", $callthis);
The purpose of the statement is to remove HTML tags from the string.
Try using the strip_tags() function: http://www.php.net/strip_tags
--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Ken Robinson writes: That doesn't look like any PHP code that I know.
Doesn't PHP support substitution with regular expressions?
I'm always getting confused between Perl and PHP.
Use the function strip_tags() to strip HTML from strings.
Thanks, I'll do that instead.
--
Transpose hotmail and mxsmanic in my e-mail address to reach me directly.
Chris Hope writes: Looks like Perl to me.
It would work in Perl. Doesn't PHP support regular expressions? I can
never remember which language supports what.
Try using the strip_tags() function: http://www.php.net/strip_tags
Done, and it works. Thanks.
--
Transpose hotmail and mxsmanic in my e-mail address to reach me directly.
Mxsmanic wrote: Chris Hope writes:
Looks like Perl to me.
It would work in Perl. Doesn't PHP support regular expressions? I can never remember which language supports what.
Yes, PHP does support regular expressions. I gave you the code for it.
Here it is again:
$callthis = preg_replace("/<[^>]*>/", "", $callthis);
--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Mxsmanic wrote: Ken Robinson writes:
That doesn't look like any PHP code that I know.
Doesn't PHP support substitution with regular expressions?
I'm always getting confused between Perl and PHP.
Use the function strip_tags() to strip HTML from strings.
Thanks, I'll do that instead.
I just wanted to add that the code looks like perl.
T
Mxsmanic wrote: I have a line like this in some PHP code on my Web page:
$callthis =~ s/<[^>]*>//g;
When the page runs, I get this error:
Parse error: parse error, unexpected '<' in /Feedback.php on line 145
this is because you've tried to use a PERL expression. in PHP, you'd
do something more like this:
$callthis = preg_replace("\<[^\>]*\>","",$callthis);
but as another poster mentioned, PHP already has a function for the
purpose you specified.
hope that clears things up for you. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: BTnews |
last post by:
Hi,
Can anyone here point me at a definitive guide or tutorial about using
escape characters when building SQL queries from user entered data?
I'm especially interested in info on this in regard...
|
by: bartek |
last post by:
Hi,
I'm aware that both quoted and angle-bracketed strings in an #include
directive result in implementation-defined file lookup, differing in the
fact that #include "foo.h" first checks...
|
by: Matthew Wieder |
last post by:
In my previous post, I asked about a routine which prepares a string for
an XPath query by taking care of escape characters.
Unable to find a list, I'm now wondering assumign I enclose the...
|
by: DotNetGruven |
last post by:
We have a web service that returns a string which happens to be well formed
XML. The client sees the string ok, except the angle brackets are HTML
encoded ( > and < ).
Is this expected...
|
by: Kenneth Porter |
last post by:
If you email your users links and wrap the links in angle brackets, beware
users using Yahoo Mail. It includes the trailing angle bracket in the link,
preventing it from working. (This was...
|
by: Peter |
last post by:
Hi,
I was wondering, can anyone tell me what statements in angle brackets are
for in VB? For example, the default
<System.Diagnostics.DebuggerStepThrough()thing that the IDE puts before
the...
|
by: Nunzio |
last post by:
I am trying to build an email address in PHP code using v5.1.2. All
works well until I try to surround the email address with angle
brackets. Every method I try causes the email address to...
|
by: pronerd |
last post by:
Hi,
I was wondering if any one knows of an easy way to add escape characters to an existing string in a BASH script.
I have a BASH script that is failing when a string is passed with brackets...
|
by: Keith Hughitt |
last post by:
Hi all,
I am using someone else's script which expects input in the form of:
./script.py <arg1arg2
I was wondering if the angle-brackets here have a special meaning? It
seems like
they...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |