I would like to take single value from the following strings(HTML tag).
<input type="hidden" name="javax.faces.ViewState" id="j_id1:javax.faces.ViewState:0" value="6857842162548399092:-3372646398158034589" autocomplete="off" />
OR
<update id="j_id1:javax.faces.ViewState:0"><![CDATA[9028765775789786807:-4669779095536779687]]></update>
For <input> tag, the expression is
<input type="hidden" name="javax\.faces\.ViewState" id=".*\:javax.faces.ViewState\:.*" value="[^"]+".*\/>
For <update> tag, the expression is
<update .*><!\[CDATA\[(.*?.*)\]\]><\/update>
In need single result 685784..89 or 90287..87.
The expression have to get single result for <input ...> or <update....>.
You can combine the two with an |("OR").
Assuming the PCRE regex flavour:
(?|(?:<input type="hidden" name="javax\.faces\.ViewState" id=".*\:javax.faces.ViewState\:.*" value="(?<value>[^"]+)".*\/>)|(?:<update .*?><!\[CDATA\[(?<value>.*?)\]\]><\/update>))
Explanation
Related
I am trying to extract only the letters from "130b2c94-22ba-4584-b18a-899eb4be045d"
<input type="hidden" name="logonInfo.forceAuthn" value="false" id="sSignOnauthenticateUser_logonInfo_forceAuthn"/>
<input type="hidden" name="logonInfo.inResponseTO" value="_130b2c94-22ba-4584-b18a-899eb4be045d" id="sSignOnauthenticateUser_logonInfo_inResponseTO"/>
<input type="hidden" name="logonInfo.issuerUrl"
I have tried
(?<=name="logonInfo.inResponseTO" value="_).*(?=" id="sSignOnauthenticateUser)
to extracts the string I need, but I need to break it down further to only the letters
Use a DOM Parser. This will reliably interpret the HTML and give you a DOM.
Then use a CSS selector query to find the input elements that have a value attribute which has a value that starts with underscore.
Finally remove all non-letters in that found value using a regex:
const html = `
<input type="hidden" name="logonInfo.forceAuthn" value="false" id="sSignOnauthenticateUser_logonInfo_forceAuthn"/>
<input type="hidden" name="logonInfo.inResponseTO" value="_130b2c94-22ba-4584-b18a-899eb4be045d" id="sSignOnauthenticateUser_logonInfo_inResponseTO"/>
<input type="hidden" name="logonInfo.issuerUrl" >`;
const doc = new DOMParser().parseFromString(html, "text/html");
for (const input of doc.querySelectorAll("input[value^=_]")) {
const letters = input.value.replace(/[^a-z]/gi, "");
console.log(input.name, ":", letters);
}
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 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.
Thank you for taking the time to look at my post.
I have an input tag that i need to have output-ed like so:
<input type="hidden" name="success_redirect" value="http://www.webpage.com?var1=${root/option1}&var2=${root/option2}" />
but i cant get that into my xslt document without it eventually rendering to
<input type="hidden" name="success_redirect" value="http://www.webpage.com?var1=$&var2=$" />
What do i put in the XSLT to allow me to get that value tag to output like i need it to?
Thanks!
Just use:
<input type="hidden" name="success_redirect"
value="http://www.webpage.com?var1=${{root/option1}}&var2=${{root/option2}}" />
Do note that if we want to output a '{' or a '}' in an attribute, we have to double them.
This is because these two characters have special meaning when used inside an attribute: they indicate the start and end of an AVT (attribute-value-template).
You can concatenate the parts:
<input type="hidden" name="success_redirect"
value="{concat('http://www.webpage.com?var1=${','root/option1}','&var2=${','root/option2}')}" />