News Articles regex

Google Apps Script: Replace soft line break for hard line break

I have this script that replaces text from Google Spreadsheet to a Google Doc. My Google doc, however, has this requirement about indentention for the line 2+ of a paragraph. Here is an example of how it should look. As we can see, when a new paragraph is added, this will begin to the left […]

Regex matching behavior between char class and EOL

With the following regex, I get the result I expect (null). It matches any character up to the period in the filename extension and that period, and then fails because nothing matches jpeg before the end of line. const fileName = ‘blog_header_one_1200_600px.jpeg’ const extractSizeRegex = /[^.]+.$/ console.log(extractSizeRegex.exec(fileName)) // null If I don’t match for the […]

is there a regex to replace this if condition

I have three string and i need to check if one of them contains the other 2 in the same order given, right now i am using alot of conditions to achive this, is there a way to simplify it using regex? here is the code: var a = ‘**’; var b = ‘##’; var […]

How to reference a variable in regex URL?

router.get("/(A|B)/account/", async (req, res) => {}); How to do I reference the (A|B) inside of the async function? Source: JavaSript – Stack Overflow

Filename validation upload in javascript

I want to restrict the user to upload a filename that contain letters, special characters and space. I would like to only allow numbers 0,1,2,3,4,5,6,7,8,9 and with a maximum of 11 numbers. Example: 54874563101.png An upload button solution in javascript will be perfect Can someone help? Thank you <button type=”button” onclick=”upload()” value=”upload” id=”buttonUpload”>Upload</button> Source: JavaSript […]

Get content in the function parameter inside a string

I have the PHP sample code : $val = "Test"; $select = mysql_safe_query(‘SELECT * FROM users WHERE username = %s’, $val); $select2 = mysql_safe_query(‘SELECT * FROM users WHERE username != %s’, $val, time()); $row = mysqli_fetch_assoc($select); print_r($row); Here the function mysql_safe_query is a custom function. Now what I am doing is parse this entire php […]

regex for stringify json

I have the following string trying to remove clean with regex {"background-color":"rgb(11,144,213);","transform":"translate(11px, 144px) transform: skew(11deg, 144deg);"} trying to find the right regex so that the final output would look like this: background-color:rgb(11,144,213);transform:translate(11px, 144px) transform: skew(11deg, 144deg); I got this so far but not quite right /[{[","|*"}]/g I’m really struggling with "," Source: JavaSript – Stack […]

Correct regex for ASCII and ASCII with accents [closed]

I would like a regex in JavaScript which takes into account only ASCII as well as ASCII with accents. Source: JavaSript – Stack Overflow

Regex to check if string contains CSS

I have a sample string. I want to test if it contains CSS or not. What will be the regex? const str ="<p style="margin-top: 0px; margin-bottom: 0px; font-size: 13px; padding: 0px; border: 0px; vertical-align: baseline; overflow-wrap: break-word; color: rgb(51, 51, 51); font-family: Roboto, sans-ser" const str1 ="This is a simple string not containing any CSS" […]

Trying to find Regex expression that start with special character

Dear Awesome programmers, Im looking for a Few (Or one if possible) Regex Expressions: Find all words start with "#" or "# " and continue with A-z letters and end by space Find all words start with "$" or "$ " and continue with A-z letters and end by space Find all words start with […]

Below regex is removing all uppercase letters though i am not trying to replace them

replaceValue(value: string){ return value.replace(/[~`%^()+={}[];:’"<>.,/?-_]/g, ”); } const text = replaceValue("Get Some Help: on regeX") Actual : "et ome elp on rege" Expected : Get Some Help on regeX Source: JavaSript – Stack Overflow

How to get specific text from a string in regex

I have a string from which I need to extract specific texts let str = ‘id = "Test This is" id ="second" abc 123 id ="third-123"’; let res = str.match(/[^id ="[](.*)[^]]/g); console.log(res); I want the texts in ids only [‘Test This is’,’second’,’third-123′] But I am getting [ ‘Test This is" id ="second" abc 123 id […]

How to count number of occurrences in a very big text for each keyword (regEx) of an array [JS]

This problem is mostly related to an optimization Suppose I have a very big text (const text = "…") and an big array of keywords (const keywords = ["one", "good days", "ar.i.t", …]). You can notice that this keywords might be a single word, multiple words or any RegEx expresion. I need to count how […]

Regex in Javascript falsely 2 octet passes 3+ digit octets [duplicate]

This is ipv4 regex, used in javascript, from, that I am running into some weird inconsistences with that do not appear in that online editor. I have let ipv4_regex = new RegExp("^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"); let values = ["", "", "12.12", "123.123", "4666.2500", "4666.2500.5.5"] values.forEach((value) => { if (ipv4_regex.test(value)) { console.log(value); } }); Expected:, Actual […]

Match failed to return array of values when the substring consists of brackets ()

I am using two strings, one is main string and another is substring. Now using match() to check if there is any match of substring in the main string. When the substring consists of brackets like ( or ) then the match value returned is null. If I remove the brackets then I see the […]

Regular expression to determine key

In my Angular application, I’m using a translation service that supports defining custom transpilers. The transpiler receives incoming translations based on the content in the translation files. Some are pure translations and you can also pass objects into translations (e.g. the label.profile.greeting translation key): { "label.startpage.welcome": "Welcome!", "": "This website is awesome. Hope you like […]

How can I disable all dates < today in ExtJS DatePicker?

I have a DatePicker in ExtJS4. I want to allow all dates > today. I am using the method ‘setDisabledDates’ where I have to use an array of dates that can include regular expressions. I think I only need a good RE for that. These are some examples of RE that I found searching the […]

How to match characters between two words / characters (@[A-Z][a-z]+(.|n)+))? [duplicate]

I need to match all the words that are between @Button and ), which I have achieved halfway, I need to do this with all the matches but the problem is that it only makes me a single match, here what I get: How can I separate into 2 matches? I want something like […]

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.