I am having to use an existing FormValidator class to check form
elements, and one of the things I must check is to see if someone
entered tags in the string <>; if so, it must flag for that.
However, the catch is that, the way FormValidator class is written, I
can't use this pattern:
/<[^>]+>/
because it needs to check for the pattern of the NEGATION of that for
FormValidator class to work. In other words, it must match the pattern
something like this:
! /<[^>]+>/
But the only way I can do this is to create a pattern and nothing
more; no other code of any kind except the literal pattern formed in
such a way to check for everything BUT a tag!
I also cannot use str_replace and strip out the tags; I can't use
htmlentities and translate the tags.. the requirements are to FLAG the
user if a tag is found but by NOT using the pattern to find one, but
to ONLY use the pattern to find the NEGATION of finding one!!!
Mind bender, I know.
HELP!
Phil 7 6223
On 29 Jan 2004 11:21:23 -0800, so*****@erols.com (Phil Powell) wrote: I am having to use an existing FormValidator class to check form elements, and one of the things I must check is to see if someone entered tags in the string <>; if so, it must flag for that.
However, the catch is that, the way FormValidator class is written, I can't use this pattern:
/<[^>]+>/
because it needs to check for the pattern of the NEGATION of that for FormValidator class to work. In other words, it must match the pattern something like this:
! /<[^>]+>/
But the only way I can do this is to create a pattern and nothing more; no other code of any kind except the literal pattern formed in such a way to check for everything BUT a tag!
I also cannot use str_replace and strip out the tags; I can't use htmlentities and translate the tags.. the requirements are to FLAG the user if a tag is found but by NOT using the pattern to find one, but to ONLY use the pattern to find the NEGATION of finding one!!!
Mind bender, I know.
Hm, another "negative-match without using !" post - just had one on
comp.lang.php: http://groups.google.co.uk/groups?th=d73f7921f5435073
Are you using POSIX regexes (ereg_*) or Perl-compatible (preg_*)? If
Perl-compatible, then a negative lookahead?
/^(?!.*<.*>)/
Start of string, NOT followed by zero or more characters with a '<' after
them, then zero or more chars, then a '>'.
(There's probably a neater way of doing it, this is just the first that comes
to mind)
--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
<http://www.andyh.co.uk> / <http://www.andyhsoftware.co.uk/space>
/^[^<>]+$/
did i get you right?
"Phil Powell" <so*****@erols.com> wrote in message
news:1c**************************@posting.google.c om... I am having to use an existing FormValidator class to check form elements, and one of the things I must check is to see if someone entered tags in the string <>; if so, it must flag for that.
However, the catch is that, the way FormValidator class is written, I can't use this pattern:
/<[^>]+>/
because it needs to check for the pattern of the NEGATION of that for FormValidator class to work. In other words, it must match the pattern something like this:
! /<[^>]+>/
But the only way I can do this is to create a pattern and nothing more; no other code of any kind except the literal pattern formed in such a way to check for everything BUT a tag!
I also cannot use str_replace and strip out the tags; I can't use htmlentities and translate the tags.. the requirements are to FLAG the user if a tag is found but by NOT using the pattern to find one, but to ONLY use the pattern to find the NEGATION of finding one!!!
Mind bender, I know.
HELP!
Phil
Andy Hassall <an**@andyh.co.uk> wrote in message news:<4v********************************@4ax.com>. .. On 29 Jan 2004 11:21:23 -0800, so*****@erols.com (Phil Powell) wrote:
I am having to use an existing FormValidator class to check form elements, and one of the things I must check is to see if someone entered tags in the string <>; if so, it must flag for that.
However, the catch is that, the way FormValidator class is written, I can't use this pattern:
/<[^>]+>/
because it needs to check for the pattern of the NEGATION of that for FormValidator class to work. In other words, it must match the pattern something like this:
! /<[^>]+>/
But the only way I can do this is to create a pattern and nothing more; no other code of any kind except the literal pattern formed in such a way to check for everything BUT a tag!
I also cannot use str_replace and strip out the tags; I can't use htmlentities and translate the tags.. the requirements are to FLAG the user if a tag is found but by NOT using the pattern to find one, but to ONLY use the pattern to find the NEGATION of finding one!!!
Mind bender, I know. Hm, another "negative-match without using !" post - just had one on comp.lang.php:
http://groups.google.co.uk/groups?th=d73f7921f5435073
Are you using POSIX regexes (ereg_*) or Perl-compatible (preg_*)? If Perl-compatible, then a negative lookahead?
/^(?!.*<.*>)/
Start of string, NOT followed by zero or more characters with a '<' after them, then zero or more chars, then a '>'.
I'm sorry I'm not familiar with the '?' used in this manner. Could
you provide some docs for me to read up more on it, I've never seen
'?' used in any other way other than as "0 or 1 instance of
something".
Thanx
Phil (There's probably a neater way of doing it, this is just the first that comes to mind)
On 30 Jan 2004 00:38:07 -0800, so*****@erols.com (Phil Powell) wrote: I'm sorry I'm not familiar with the '?' used in this manner. Could you provide some docs for me to read up more on it, I've never seen '?' used in any other way other than as "0 or 1 instance of something".
(? is the start of several constructs; this one is (?! - zero-width
negative look-ahead assertion.
See the manual: http://uk.php.net/manual/en/pcre.pattern.syntax.php
--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
<http://www.andyh.co.uk> / <http://www.andyhsoftware.co.uk/space>
Andy Hassall <an**@andyh.co.uk> wrote in message news:<nq********************************@4ax.com>. .. On 30 Jan 2004 00:38:07 -0800, so*****@erols.com (Phil Powell) wrote:
I'm sorry I'm not familiar with the '?' used in this manner. Could you provide some docs for me to read up more on it, I've never seen '?' used in any other way other than as "0 or 1 instance of something".
(? is the start of several constructs; this one is (?! - zero-width negative look-ahead assertion.
See the manual: http://uk.php.net/manual/en/pcre.pattern.syntax.php
That was more than I could absorb. Do you have a much easier site to
learn how ?! and all work? I believe they are called "lookaheads" or
something.
Phil
On 31 Jan 2004 11:52:43 -0800, so*****@erols.com (Phil Powell) wrote: That was more than I could absorb. Do you have a much easier site to learn how ?! and all work? I believe they are called "lookaheads" or something.
If you look for Perl regular expression tutorials they should be mostly
applicable, and are probably more widely available than looking for
PHP-specific ones.
--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
<http://www.andyh.co.uk> / <http://www.andyhsoftware.co.uk/space>
Thanx I looked at several of them online and I'm no closer to
understanding them than I was before I ever learned about them.
Technical retardation I'm afraid.
Phil
Andy Hassall <an**@andyh.co.uk> wrote in message news:<01********************************@4ax.com>. .. On 31 Jan 2004 11:52:43 -0800, so*****@erols.com (Phil Powell) wrote:
That was more than I could absorb. Do you have a much easier site to learn how ?! and all work? I believe they are called "lookaheads" or something.
If you look for Perl regular expression tutorials they should be mostly applicable, and are probably more widely available than looking for PHP-specific ones. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Lasse Edsvik |
last post by:
Hello
I was wondering if you guys could help me. im building a small messageboard
and i want to filter all html-tags except these ones:
<b> <i> <img.........> <font....>
how to build such...
|
by: Donald Firesmith |
last post by:
Are html tags allowed within meta tags? Specifically, if I have html
tags within a <definition> tag within XML, can I use the definition as
the content within the <meta content="description> tag? ...
|
by: James Geurts |
last post by:
Hi all
Can someone help me out with a regex to remove all html tags except for <p>,</p>,<br>,<br/> from a string
Thank
Jim
|
by: Rakesh |
last post by:
Im using a cutom control to try to validate a text box to ensure that on the client side a validation expression is present to prevent the user from posting back html in their text box. I was only...
|
by: news.microsoft.com |
last post by:
I need help design a reg exp.
I am parsing an html file to get the input values, here is one example
<input VALUE="Staff Writer" size=60 type="text" name="author">
Can I grab the value "Staff...
|
by: jiing24 |
last post by:
I try to use regexp to replace some html tags in DOM, but the result
seems some problems,
================================
<Script language="javascript" type="text/javascript">
var config =...
|
by: ojsimon |
last post by:
Hi
I found this script on a forum and have been trying to make it work, but all it returns is a blank screen, i tried using the debug error reporting but got nothing from that either just a blank...
|
by: chainspell |
last post by:
My very first post here :) I know my way around vb and js but I'm lost with regular expressions.. Anyways I have my function below, and my problem is the function changes all words into links... even...
|
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: 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...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
| |