I am trying to search a string in eclipse.
<input type="text" autocomplete="off" />
<input type="text" sacsacdfsre />
I want to search all input elements of type text and exclude elements with autocomplete.
Search input and text and exclude autocomplete
I am trying
input.*text.*^(autocomplete)
how can we solve this.
Try something like this:
<input[^>]+type="text"(?![^>]*autocomplete).*?>
Working example on RegexPal
Related
I have a HTML form which currently has unique id's for each input (or select) like so.
example 1
<input type="number" id="qty-a-row" min="0" max="999" autocomplete="off" value="" style="border:0px; outline:0px; display:inline-block; width:50px;" />
example 2
<select id="ps_a_row" autocomplete="off" style="width:324px; border:0px; outline:0px; display:inline-block">
each id is unique. I'm now trying to add in a name="" with the same value as every id="" found so example 1 above becomes.
<input type="number" id="qty-a-row" name="qty-a-row" min="0" max="999" autocomplete="off" value="" style="border:0px; outline:0px; display:inline-block; width:50px;" />
and example 2 becomes...
<select id="ps_a_row" name="ps_a_row" autocomplete="off" style="width:324px; border:0px; outline:0px; display:inline-block">
and so on for every id="anything" it finds.
I'm using notepad++ and with regex ticked currently trying...
Find = id="(.*)"
Replace = id="\1" name="\1"
but this is only finding some id's and duplicates all other tags it finds after the id it finds too.
The complete code for the form I'm trying to edit is here...
https://pastebin.com/ZAE4Gffk
Find id="([^"]+)" and replace it with id="\1" name="\1" , but you shouldnt use regex for HTML manipulation. Use appropriate tools for that.
Demo
I have about 1,000 lines of html that look like this:
<input type="text" readonly value="some-value-here" class="unit size1of2" />
I am able to find all of those lines using the RegEx search of
<input type="text" readonly value="[^<]+" class="unit size1of2" />
However, I am trying to change all of them to
<input type="hidden" value="same-value-that-was-found" />
Any ideas on what I need to do to accomplish this?
I'm trying the pattern attribute for the first time, and I can't get it to work (my browser does support it, though).
Right now I have:
input type="text" pattern="[a-zA-Z0-9]{6}" name="formName"
The first problem is that is doesn't notify me if it's blank; the second problem is that if I do type in something, it won't accept it. I want it to accept alphanumeric characters and be exactly 6 characters is length. I tried it with forward slashes and a few other variations.
As Duikboot already pointed out, the right way to do it is:
<input type="text" name="formField" pattern="[a-zA-Z0-9]{6}" required>
The required attribute causes the validation to fail, when the field is empty.
The pattern attribute defines the regex to test against, when the field is not empty.
(Your initial pattern seems to work fine.)
More info can be found here.
This is simple enough so as not to require a demo, but nonetheless you can find one here.
Works for me here : http://jsfiddle.net/barbuslex/nR6yg/
<form>
<input type="text" pattern="[a-zA-Z0-9]{6}" name="formName" />
<input type="submit" value="OK" />
</form>
I use Google Chrome
You simply need to add the required attribute to your tag, which will notify the user if they attempt to send the form with that very field blank.
<input type="text" pattern="[a-zA-z0-9]{6}" name="formName" required>
Try this code its working perfectly
<html>
<body>
<form action="demo_form.asp">
Country code: <input type="text" name="country_code" pattern="[A-Za-z]{3}" title="Three letter country code">
<input type="submit">
</form>
</body>
</html>
Enter invalid country code and click submit button. Then You can get a message (title="Three letter country code")
I have an input text box in my HTML form which looks for a regex pattern as shown below.
I am looking for anything to be entered other than white spaces or blank. I tried all the following below and none of them is allowing me to enter any normal text such as "hello world" and "helloworld" in it.Any suggestions are most welcome. Thanks
<input name="item" type="text" size="25" autofocus="autofocus" pattern="^\S$" title="Enter something valid"/>
<input name="item" type="text" size="25" autofocus="autofocus" pattern="^[^\s]*$" title="Enter something valid"/>
<input name="item" type="text" size="25" autofocus="autofocus" pattern="^[\S]*$" title="Enter something valid"/>
EDIT:
after removing the anchor, this works for "helloworld" but not for "hello world". So I think it has to do with regex pattern.
<input name="item" type="text" size="25" autofocus="autofocus" pattern="[^\s]*" title="Enter something valid"/>
[^\s]* will match against anything that contains no spaces, so a space in the words will not match.
You probably want something like .*[^\s].* to match a string with at least one non-space character.
The required attribute is probably the best way to guard against blanks (or ^$ should work).
I need a regex to match all self-closing <input /> tags which lacks a type attribute.
For example, I want to find these:
<input size="1" />
<input name="test" />
But not this:
<input type="radio" />
Please note, this should be adaptable for any single attribute. I am just using type here as an example.
FYI, I am performing a search across 1000s of .html files using AstroGrep.
You can assume that the attribute is well-formed, with equals sign and double quotes.
<input(?:\s+(?!type=)\w+="[^"]*")*\s*/>
That should work if AstroGrep's regex flavor isn't too exotic. I can't find an online reference for it.
I don't know what is AstroGrep, but if it has negative look-ahead, you could just do
(?!\<input(?:[[:space:]]+[a-zA-Z0-9_]+="[^"]*")*(?:[[:space:]]+type="[^"]*"))<input(?:[[:space:]]+[a-zA-Z0-9_]+="[^"]*")*[[:space:]]*/>
Without it, it is much more laborious.