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 6207
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: Mushico |
last post by:
How to calculate date of retirement from date of birth
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
| |