Regular expression to replace <br style="..."> by <br style="..."/> [closed] - html

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I need a regular expression to help me close the <br> tag to comply with the xhtml standard. In my html br does not always comes empty, so the regex has to account for it. Thanks in advance for your help.

Look for this pattern
(\<br[^\>]*)(\/)?(\>)
And replace with this
$1/$3
Based on the engine you may need to use \1/\2 instead of $1/$3 in the replacement string.

The regex might also look a bit simpler:
replace
/<br.*?>/i
with
<br\/>

Related

Word count regex in HTML [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed last month.
Improve this question
This is the same question as this. But since I'm not using javascript, 'innerText' is not a solution for me and I was wondering if it was possible for regex to combine /(<.*?>)/g and /\S+/g to get the actual word count without having to make a bunch of string operations.
The language I'm using here is Dart, if a solution I haven't found already exist within it that would work too as an answer. Thanks !
Edit : Someone edited the tags ? This question is not Dart-specific and is about regex, so I'm putting them back as they were.
Edit 2 : The question was closed because it is not "focused", but I do not know how I can make "if it was possible for regex to combine /(<.*?>)/g and /\S+/g" any more focused.
Assuming all text is enclosed in HTML elements, you can use (?<=>|\s)[^<\s>='"]+?(?=<|\s).
With the string <p>One</p><p>Two Three, Four. Five</p><p>Six</p> there are six matches.
Note:
It uses a lookbehind group, which might not be supported in all browsers.
Punctuation at the end of words are grouped with them, e.g. "three," so keep that in mind if you're planning to use the actual words and not just count them.

Is Ragel a declarative way of regexp or it has more than that? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 months ago.
Improve this question
I was reading an HTML parser article and noticed that they used Ragel for parsing a web page. Is it because it is more readable than using regexp or there is a different meaning behind it?
I read several things about Ragel, but they were too complex for my understanding. It would be cool if somebody gave an example of Ragel.

Edit text in HTML [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have an h1 header on my page that simply says "Hello world".
I want to know how I can add a form to change the header to say "Hello world from my_form_field_value".
It depends on the technology you are using (jQuery, ASP(.NET), PHP, etc).
user3047190's answer used jQuery (client side solution). If using a server side solution, you can have the form send a querystring containing the text to the server and return a page with the text you just typed in.
Here's an online example: http://html.net/tutorials/asp/lesson11_ex1.asp
Here's the tutorial explaining the above classic ASP example: http://html.net/tutorials/asp/lesson11.asp
This question is horribly phrased so I'm afraid I will answer your question with other answers.
What I believe you want is on input change, you want to capture the change (Detecting input change in jQuery?) and update the h1 text: $("h1").text("newString");
(that will only work with jquery included)

How to use 2 conditions in an if statement in html [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I've looked everywhere Google leads me and found no answers. Help? Also, another question is how do I make a condition to check whether a textbox is filled with something or is left blank. I'm sorry for the n00b questions. I'm really new to html and programming in general. Thanks!
HTML is a markup language and doesn't have if statements. You'd need to use JavaScript to check whether something has a value.
Check out MDN's article on if...else for more information.

User formatting for textarea [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
A perfect example is stackoverflow. When a user types a question, the textarea give the user basic formatting options such as bullet points, numbering, italicize, etc. How can I create a similar textarea? I am currently using html, css and php.
You can use javascript (or more effectively jQuery) to create your own textarea with this behaviour, or look at an existing package such as TinyMCE and configure it to meet your requirements (the approach I would suggest): http://www.tinymce.com/
Easiest way would be to use an editor like TinyMCE: http://www.tinymce.com/
There are others as well, but TinyMCE is what I see used most.