match
Lua need to split at comma
Try this str=”cat,dog” for word in string.gmatch(str, ‘([^,]+)’) do print(word) end ‘[^,]’ means “everything but the comma, the + sign means “one or more characters”. The parenthesis create a capture (not really needed in this case).
Javascript Regexp loop all matches
I agree with Jason that it’d be faster/safer to use an existing Markdown library, but you’re looking for String.prototype.replace (also, use RegExp literals!): var Text = “[Text Example][1]\n[1][http: //www.example.com]”; var rePattern = /\[(.+?)\]\[([0-9]+)\]/gi; console.log(Text.replace(rePattern, function(match, text, urlId) { // return an appropriately-formatted link return `<a href=”https://stackoverflow.com/questions/5835418/${urlId}”>${text}</a>`; }));
how to check if string contains ‘+’ character [duplicate]
You need this instead: if(s.contains(“+”)) contains() method of String class does not take regular expression as a parameter, it takes normal text. EDIT: String s = “ddjdjdj+kfkfkf”; if(s.contains(“+”)) { String parts[] = s.split(“\\+”); System.out.print(parts[0]); } OUTPUT: ddjdjdj
Search and replace specific query string parameter value in javascript
a_href = a_href.replace(/(test_ref=)[^\&]+/, ‘$1’ + updated_test_ref);
How to use multiple cases in Match (switch in other languages) cases in Python 3.10
According to What’s New In Python 3.10, PEP 636, and the docs, you use a | between patterns: case ‘Egide’ | ‘Eric’:
JavaScript error: “val.match is not a function”
I would say that val is not a string. I get the val.match is not function error for the following var val=12; if(val.match(/^s+$/) || val == “”){ document.write(“success: ” + val); } The error goes away if you explicitly convert to a string String(val) var val=12; if(String(val).match(/^s+$/) || val == “”){ document.write(“success: ” + val); … Read more
How to pass a variable into regex in jQuery/Javascript
Javascript doesn’t support interpolation like Ruby — you have to use the RegExp constructor: var aString = “foobar”; var pattern = “bar”; var matches = aString.match(new RegExp(pattern));
What does the “Nothing to repeat” error mean when using a regex in javascript?
You need to double the backslashes used to escape the regular expression special characters. However, as @Bohemian points out, most of those backslashes aren’t needed. Unfortunately, his answer suffers from the same problem as yours. What you actually want is: The backslash is being interpreted by the code that reads the string, rather than passed … Read more