java 正则匹配 sql星号,正则表达式匹配星号和换行符之间的字符串
Example:
blah blah * Match this text Match this text
Match this text
Match this text
Match this text
*
more text more text
How to get string from inside the asterisk with the line breaks?
解決方案
You can use a negated match here. Notice that I escaped \ the literal newline for this example.
var myString = "blah blah * Match this text Match this text\
Match this text\
Match this text\
Match this text\
*\
more text more text";
var result = myString.match(/\*([^*]*)\*/);
console.log(result[1]);
// => " Match this text Match this text Match this text Match this text Match this text "
If you don't want the leading or trailing whitespace, you can use the following to make it non greedy.
var result = myString.match(/\*\s*([^*]*?)\s*\*/);
console.log(result[1]);
// => "Match this text Match this text Match this text Match this text Match this text"
總結(jié)
以上是生活随笔為你收集整理的java 正则匹配 sql星号,正则表达式匹配星号和换行符之间的字符串的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 基于vue3.0全家桶H5模板
- 下一篇: 线程下的udp和tcp局域网聊天