5 Replies - 1432 Views - Last Post: 26 June 2014 - 11:08 PM
Posted 19 June 2014 - 02:53 AM
I want to detect that:
This validation will be done in the code behind to check that the user is doing things correctly.
Posted 20 June 2014 - 01:50 AM
<script>alert('some text here');</script>
But what if the user uses a different approach. Like:
<script>var a='some text here';alert(a);</script>
Is regex still the technology to use in this case? I have to make sure that the variable declared is the same variable used inside the alert().
Posted 20 June 2014 - 09:41 PM
Posted 23 June 2014 - 04:26 AM
Posted 26 June 2014 - 11:08 PM
It's just a simple textbox for the pattern and another textbox for the string. A label shows "Matching" or "Not Matching" after button click.
Playing around in my little playground, I can't seem to find a solution for my new regex problem.
For example, I have this:
var a1='hi '; var b2='username';alert(a1 + b2);
Using backreferences, I can call variables a1 & b2 again in the alert.
But what do I do about the declaration of the second variable(b2 variable)? I need a variable that is composed of letters, numbers, or underscore that does not have special characters (following the rule of a variable). So I have...
At the same time, the second variable should not be equal to the first variable. This is where I'm stuck.
I need a logic AND. Some references say I can achieve this with (?=pattern)
I need to say that it should not be equal to the first variable.
[^\1] doesn't work. It seems that backreference doesn't work inside brackets.
Character class subtraction doesn't seem to help either.
Could someone guide me on how to achieve this?
This post has been edited by November-06: 26 June 2014 - 11:15 PM