Help With Regular Expression

J

Joey

Hello guys, I'm trying to learn about regular expressions. I need to
be able to use an RE that can evaluate for STRINGS (or specific
sequences of characters), not just occurances of characters.
Everything I have read thus far involves checking only for the
presence or absence of characters. Can anyone provide an RE that will
correctly evaluate a string to see if it contains other strings,
specifically these (omit the quotes)..."<script>", "<object>",
"<html>", "<head>", "<body>" and/or "<form>".
 
G

Guest

Hello guys, I'm trying to learn about regular expressions. I need to
be able to use an RE that can evaluate for STRINGS (or specific
sequences of characters), not just occurances of characters.
Everything I have read thus far involves checking only for the
presence or absence of characters. Can anyone provide an RE that will
correctly evaluate a string to see if it contains other strings,
specifically these (omit the quotes)..."<script>", "<object>",
"<html>", "<head>", "<body>" and/or "<form>".

Joey,

if you have a string like this

"hello blabla some text <script> again <object> again over"

Then you can find if it contains "<script>" by using

"\<script\>"

If you need to find if it contains more than one string, for example
"<script>" and "<object>", you should either use

"\<script\>|\<object\>" <--- it means "<script>" OR"<object>"

with an additional check in the code to see if both of them are there,
or you can do

"\<script\>(.|\n)*?\<object\>"

which means "look for <script> and for <object> with any number of
characters, or line brakes in between"
 
J

Joey

Joey,

if you have a string like this

"hello blabla some text <script> again <object> again over"

Then you can find if it contains "<script>" by using

"\<script\>"

If you need to find if it contains more than one string, for example
"<script>" and "<object>", you should either use

"\<script\>|\<object\>" <--- it means "<script>" OR"<object>"

with an additional check in the code to see if both of them are there,
or you can do

"\<script\>(.|\n)*?\<object\>"

which means "look for <script> and for <object> with any number of
characters, or line brakes in between"

I have a webpage that has a textbox to take input as text, html tags
and css. Then right under is a second one that will, on postback,
display/markup the entered data from the first textbox. I used a
regular expression validator and entered \<script\> as the validation
expression.

When I enter data, including a <script> tag and then click the
"Preview" button, the page posts back (why?) and then two javascript
errors occur...

Line: 168
Char: 1
Error: Syntax error
Code: 0
[page]

Line: 224
Char: 1
Error: 'ctl00_conMain_vsmEnter' is null or not an object
Code: 0
[page]

In the js errors above, 'vsmEnter' is what is (supposed to be?)
rendered off of my validation summary server control.

In any case, I shouldn't be getting these errors, because the regular
expression validator should be blocking the postback when I enter
<script> in the first textbox. The only thing I can think of is I must
have the wrong validation expression entered - \<script\> is not
working. I just need a validation expression that will allow for me to
detect if any of the following is entered in the first
textbox...<script> <object> <html> <head> <body> <form>

Does anyone have any ideas about what else I can try?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,207
Latest member
Best crypto consultant

Latest Threads

Top