I have some large forms & instead of converting these forms to emails by hand I thought it would be faster if I could just search & replace using Dreamweavers RegEx functions -http://www.adobe.com/devnet/dreamweaver/articles/regular_expressions_pt1.html
Basically, I have some input values that I need to pull the input id's from & make into a value like [MyId,Form]
EXAMPLE INPUT:
<input name="PreviousReading100" id="PreviousReading100" type="number" style="width:200px; color:#666;" class="clear-default ForceNumber html5" value="[|PreviousReading100]" />
RESULT REQUIRED:
[PreviousReading100,Form]
--HAVE TRIED--
FIND:
<input\b(?=((?!(/>|id="?[0-9a-zA-Z]*")).)*id="?[0-9a-zA-Z]*").*?/>
REPLACE:
[$2,Form]
RESULT:
[id="PreviousReading100",Form]
Try
Replace <input(\s+\w+="(.*?)")*\s+id="(.+?)"(\s+\w+="(.*?)")* />
With [$3,Form]
Related
I have to change a lot of tags in an XML-Document and think RegEx might be the best solution for this, but I can't figure out the correct snytax:
<tag1 attribute="value1">random content1<tag1>
<tag1 attribute="value2">random content2<tag1>
<tag1 attribute="value1">random content3<tag1>
This is the current state. "tag1" can have different values for "attribute" at the moment. The new structure gets rid of those combinations, but instead uses specific elements for that.
<tag1 attribute="value1">random content1<tag1>
<!-- tag1 + value1 requires <tag2>random content1</tag2> : -->
<tag2>random content1<tag2>
<tag1 attribute="value2">random content2<tag1>
<!-- tag1 + value2 requires <tag3>random content2</tag3> : -->
<tag3>random content1<tag3>
I need to change all of those tag->attribute-combinations without touching the content inbetween. Is it possible to select those specific tags while excluding their contents?
Help is very appreciated!
I am using Thymeleaf #lists.contains but cannot get this scenario to work.
I have an ArrayList in Java as such:
List<String> data = new ArrayList<String>();
The list conatins numbers: [1,2,3]. Now in Thymeleaf I want to check if a number is in a list then print my checkbox as checked, I am trying this:
<input type="checkbox" th:if="${#lists.contains(data,1)}" name="checklist" checked="true" />
<input type="checkbox" th:unless="${#lists.contains(data,1)}" name="checklist" />
This does not work. None of the checkboxes are checked. I would have expected for the 1 in the list and the 1 in the if to match and check the checkbox.
For some reason Thymeleaf is not working like this. If I append all the values with something like a c, example ['c1','c2','c3'] and test for that, then it works perfectly. So is it an number/string testing problem and how do I get it to work without appending a character to the number?
If I print the variables out, I get this:
${#lists.contains([1],1)} = false
${#lists.contains([1],'1')} = true
So if I had to use variable on both side, how would I add the quotes?
I tried this but it does not work:
${#lists.contains(data,"numvar")}
If you have an array of Strings, you have to search using a string:
<input type="checkbox" th:if="${#lists.contains(data, '1')}" name="checklist" checked="true" />
Just like the java:
List<String> strings = new ArrayList<>(Arrays.asList("1","2","3"));
System.out.println(strings.contains(1)); // returns false
System.out.println(strings.contains("1")); // returns true
If you have an array of Integers, you have to search using an Integer:
<input type="checkbox" th:if="${#lists.contains(data, 1)}" name="checklist" checked="true" />
Just like the java:
List<Integer> integers = new ArrayList<>(Arrays.asList(1,2,3));
System.out.println(integers.contains(1)); // returns true
System.out.println(integers.contains("1")); // returns false
So the way I fixed this was to do this:
${#lists.contains(data, '' + numvar + '')}
Just to recap, the data variable is an ArrayList of Strings. The numvar variable is an int number. To compare the two you have to wrap the numvar around single quotes, and this is how you have to do it. Thanks Metroids for pointing it out.
to find the value in array, this worked for me:
<input type="checkbox" th:name="plates[]" th:checked="${#arrays.contains(array, 1)} ? 'checked'" th:value="${plate.id}">
I am trying this html code to limit the input field to nine-digit rule, with a maximum value possible of 999999999.
<input name="field" type="number" max="999999999" pattern=".{9,9}">
However this code will check the maximum but will allow things like:
9
999
9999
99999
When what should be allowed is:
123456789
111111111
789531156
What is wrong?
I am only interested in html5 solution.
The pattern attribute doesn't seem to work for inputs of type "number" (at least in Chrome). However, you can set the min value like this:
<input name="field" type="number" max="999999999" min="100000000">
Or use a simple "text" input like this:
<input name="field" type="text" pattern="\d{9}">
Demonstration
I have the following XML snippet:
<figure customer="ABC DEF">
<image customer="ABC"/>
<image customer="XYZ"/>
</figure>
I'd like to check if the figure element's customer attribute contains the customer attributes of the image elements.
<xsl:if test="contains(#customer, image/#customer)">
...
</xsl:if>
I get an error saying:
a sequence of more than one item is not allowed as the second argument of contains
It's important to note that I cannot tell the values of the customer attributes in advance, thus using xsl:choose is not an option here.
Is it possible to solve this without using xsl:for-each?
In XSLT 2.0 you can use:
test="image/#customer/contains(../../#customer, .) = true()"
and you will get a true() result if any of them are true. Actually, that leads me to suggest:
test="some $cust in image/#customer satisfies contains(#customer, $cust)"
but that won't address the situation where the customer string is a subset of another customer string.
Therefore, perhaps this is best:
test="tokenize(#customer,'\s+') = image/#customer"
... as that will do a string-by-string comparison and give you true() if any of the tokenized values of the figure attribute is equal to one of the image attributes.
I have an application that I have inherited that dynamically builds HREF links within the displayed text. All seemed to be working well until we recently did a database change and our list of terms to link started to get returned from the query in a different order. This exposed a bug within the existing REGEX where it tries to place an HREF link within a preexisting HREF. Simply forcing a new ordering on the terms list is not an option. A term could be just one word, could be multiple words and even could be words formatted using HTML.
What would I need to adjust within the REGEX so that it ignores terms within the HREF attribute of an A element? Here is an example of what I am referring to:
<cfset Output = "This is some sample text to show the problem when we have term1 term2." />
<cfloop index="w" list="sample;term1 term2;term1" delimiters=";">
<cfset Output = "." & Variables.Output & "." />
<cfset Output = REReplaceNoCase(Variables.Output, "(?![</]#w#>)(\W)(#w#)(\W)", "\1\2\3", "one") />
<cfset Output = Mid(Variables.Output, 2, Len(Variables.Output)-2) />
</cfloop>
<cfoutput>#Variables.Output#</cfoutput>
Change the first (\W) in the regex to ([^=\w>]) and the second to ([^=\w<])
<cfset Output = REReplaceNoCase(Variables.Output, "(?![</]#w#>)([^=\w>])(#w#)([^=\w<])", "\1\2\3", "one") />