Skip to content

Tag: regex

Text and emoji extraction from HTML

I need to perform text and emoji extraction from HTML (I have no control over the HTML I get). I found it fairly simple to remove HTML tags using the following function; however, it strips out the emojis embedded within an <img> tag. The result should be plain text + emoji characters. I don’t care…

Regex split string at specific set of characters

Suppose I have a string of this nature Set 1 (2) Set 2 (2) Set 3 (2) Set 4 (2) [Choose Two]. How can I make a regex that starts after (important that it’s after or I can just add it back) every ) character and optionally ends at a ] character, so splitting the string would look something like

JavaScript: Search string from position

JavaScript has two useful methods, both which nearly do what I need. String.prototype.indexOf() will search for a substring and return its position. It has an optional position parameter which is the starting point of the search, so you can easily find the next one. String.prototype.search() will search a str…

Using regex to capture a value in a text line

I have a text line and I need capture the value “Keyword” key. In this sample the value is “ConquestImageDate”. With my code below I can capture the value as ConquestImageDate”. But it has a ‘”‘ on the end. I know I can use a replace to get rid off it. But, I´d …