This question already has answers here:
How do I make JSP tag files NOT ignore all whitespace?
(4 answers)
Closed 8 years ago.
I have one line of html in a form on a JSP page like this:
<c:forEach var="entry" items="${set}">
<input type="checkbox" name="thing" value="${entry.key} ${entry.value}">
</c:forEach>
However, the space between the key and the value ${entry.key} ${entry.value} is lost when the form is submitted. I've tried using a \ before the , in that case both the \ and the are still there when submitting.
It seems that Java EL does not preserve isolated spaces, is that right? If so, is there a valid workaround?
EDIT: This is so silly of me, many thanks to Cthulhu. But I still don't understand the behavior after adding a \. Why would that cause the space to show?
You can insert white-spaces using:
Character Entity References
Edit: Seems to be a bug in the way spaces are handled by the EL parser, so you should use either html entities like or the other ways outlined here.
${entry.key}${' '}${entry.value}
was my way to fix this. Seems a little less verbose than the
<c:out value="${bean.foo} ${bean.bar} ${bean.waa}" />
from the other thread.
Related
This question already has answers here:
RegEx match open tags except XHTML self-contained tags
(35 answers)
Closed 1 year ago.
I've been searching for a solution for hours, but haven't found any examples that help.
I want to search a plain text file and remove all instances of <a id="pageXXX"></a> where XXX is the page number.
I have tried
(^<a id="page)(.*:?)("></a>)
(^<a id=\\"page)(.*:?)(\\"></a>)
(^<a id="page)([0-9]+)("></a>)
(^<a id=\\"page)([0-9]+)(\\"></a>)
What am I missing?
This works correctly.
(<a id=\"page)(.*:?)(\"></a>)
This question already has answers here:
How to style text of submit button
(3 answers)
Closed 2 years ago.
We can use the tag(superscript tag) to represent something like a^b and e^x in html5. But while using the tag to make a button, we normally use the 'value' attribute to represent what's gonna be on the button something like this:
<input type="button"class="cutedog" value ="x cube">
But we can't really use the sup tag inside the " " because it just prints out the exact thing out something like this: "e(sup)x(/sup)" (I have deliberately put () instead of < and > because stackoverflow does't support this :( )
Anyway can you tell me that how can we put e^x inside "" or is there any way to do this?? Plz help me :))
<button>x<sup>3</sup></button>
This question already has answers here:
Is it guaranteed that non-numeric attribute values on every web-page HTML are always quoted?
(1 answer)
what are data-* HTML attributes?
(1 answer)
Closed 4 years ago.
In the code I am working on I found this:
<div class="icon icon2 screen-icon" data-screen-idx=1>
What puzzles me is the last "attribute" (or whatever it is )
Is this data-screen-idx-1 legal in html tag?
Please note that 1 is not quoted.
If yes, where can I find info about this.
If not, why would someone write such thing?
Yes, this is valid HTML. They are called "data-attributes" and can be whatever you want, as long as they begin with data-.
See this article for more information. MDN - Using data attributes
This question already has answers here:
Multiple lines of input in <input type="text" />
(10 answers)
Closed 6 years ago.
I've been having a bit of trouble with a problem that seems as though it should be obvious, but my internet searches yield no results. Essentially, I'm trying to create an image-board like HTML skeleton for a project. However, my text entry box (resized to allow for entrance of more than a few words, doesn't allow for entry of more than one line (hitting enter does not start a new line, and arrow keys don't work either.)Keep in mind that I cannot use javascript or any server side languages. What should I do with this?
The id of the textbox is #postbigger - I heard there was a rows style, but upon trying it got no results. Is there some form of css descriptor I can add? ( This is not a duplicate, as I needed to actually apply the code and remove the resizable effect on )
#postbigger {
height:100px;
width:300px;
font-size:14px;
}
<form>
Post:<br><input id="postbigger" type="text"/><br>
Id Code:<br><input type="text"/>
</form>
Use <textarea>
<textarea rows='6' cols='40'></textarea>
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Regular expression to remove HTML tags
Is there an expression which will get the value between two HTML tags?
Given this:
<td class="played">0</td>
I am looking for an expression which will return 0, stripping the <td> tags.
You should not attempt to parse HTML with regex. HTML is not a regular language, so any regex you come up with will likely fail on some esoteric edge case. Please refer to the seminal answer to this question for specifics. While mostly formatted as a joke, it makes a very good point.
The following examples are Java, but the regex will be similar -- if not identical -- for other languages.
String target = someString.replaceAll("<[^>]*>", "");
Assuming your non-html does not contain any < or > and that your input string is correctly structured.
If you know they're a specific tag -- for example you know the text contains only <td> tags, you could do something like this:
String target = someString.replaceAll("(?i)<td[^>]*>", "");
Edit:
Ωmega brought up a good point in a comment on another post that this would result in multiple results all being squished together if there were multiple tags.
For example, if the input string were <td>Something</td><td>Another Thing</td>, then the above would result in SomethingAnother Thing.
In a situation where multiple tags are expected, we could do something like:
String target = someString.replaceAll("(?i)<td[^>]*>", " ").replaceAll("\\s+", " ").trim();
This replaces the HTML with a single space, then collapses whitespace, and then trims any on the ends.
A trivial approach would be to replace
<[^>]*>
with nothing. But depending on how ill-structured your input is that may well fail.
You could do it with jsoup http://jsoup.org/
Whitelist whitelist = Whitelist.none();
String cleanStr = Jsoup.clean(yourText, whitelist);