specialChars not identifying correct regular expression
See original GitHub issueI have the following regular expression:
/\[\[\s?date\(\'([0-9a-zA-Z\s\:\-\+]*)\'(\s?,\s?\'([a-zA-Z \-\:]*)\')?\)\s?\]\]/g
Which matches the following string:
I went for a walk on '[[date('last week', 'Y-m-d')]]' and '[[ date('today') ]]'
Results can be seen here:
https://regex101.com/r/XC8gQT/2
However, when I try to use the regular expression with specialChars
, the text is not replaced as I would expect.
The code I’ve used is:
window.onload = function() {
editor = CodeMirror.fromTextArea(document.getElementById("query"), {
lineNumbers: true,
mode: "text/x-mysql",
matchBrackets: true,
specialChars: /\[\[\s?date\(\'([0-9a-zA-Z\s\:\-\+]*)\'(\s?,\s?\'([a-zA-Z \-\:]*)\')?\)\s?\]\]/g,
specialCharPlaceholder: function(ch) {
var node = document.createElement("span");
node.innerHTML = 'it-works';
node.className = "special";
node.title = 'It works!';
return node;
}
});
};
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
specialChars not identifying correct regular expression #4271
The code I have has placeholders, which i'd like to apply some CSS to or add a class. Such a placeholder would be...
Read more >Regex pattern including all special characters - Stack Overflow
Regex just starts at the ascii index and checks if a character of the string is in ... However you can think of...
Read more >Special characters in regexes and how to escape them - Threesl
Information on special characters in regular expressions and how you can escape them to include them in your match.
Read more >Regular Expression (Regex) Tutorial
Regular Expression, or regex or regexp in short, is extremely and amazingly powerful in searching and manipulating text strings, particularly in processing ...
Read more >Regex Tutorial - Literal Characters and Special Characters
The most basic regular expression consists of a single literal character, such as a. It matches the first occurrence of that character in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Nope, sorry, I am not being paid enough to act as a help desk.
Could you provide a small code sample to get me started?