Comments (9)
Oniguruma has variable syntax/behavior function.
I don't know which syntax mode you are using.
If you are using default syntax(== Ruby), then [^\/] can match a newline.
ONIG_SYN_NOT_NEWLINE_IN_NEGATIVE_CC flag is disabled in default syntax.
if /(/)(?=[^\/]/[ix])/ =~ "/\n/ix"
puts "MATCH"
else
puts "NOT MATCH"
end
==> MATCH
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
You should go to ruby community if you ask about behavior of ruby regexp.
from oniguruma.
Thank you very much for the reply! π
I'm trying to fix some bug of the Ruby language package of Atom, which I believe is using oniguruma as their regex engine. Actually, the bug is the package can't recognize a multi-line regex. The problem lies somewhere in
(?<![\\w)])((/))(?![?*+])
(?=
(\\\\/|[^/])*
/[eimnosux]*\\s*
)
which is basically a more verbose version of the previous example. It's really tricky to differentiate the division operator /
and regex delimiter /
without parsing the Ruby code. π
from oniguruma.
I even tried ((/))(?=[^/]*/)
, it matches a single-line regex, but still not multi-line regex, so I suspected that [^/]
in the lookahead doesn't match a LF.
Now that I think about it, maybe I've looked into the wrong spot.
from oniguruma.
I have never used Atom. I don't know about it.
But if atom/language-ruby uses oniguruma as regexp engine, why the package.json dosn't include dependencies to oniguruma module.
Is Atom running on JavaScript on Browser?
from oniguruma.
Pretty much, it's written in CoffeeScript, to be exact, and running on Node.js. The UI is basically parsed HTML and CSS, I guess you can call it a desktop editor created with Web technologies π
why the package.json dosn't include dependencies to oniguruma module
It has, in the core: https://github.com/atom/atom/blob/9ea68024acccd7dc7494f50d03496c16b193c0c4/package.json#L46
I think oniguruma backs up all its language packages, and also the find-and-replace feature.
from oniguruma.
I have installed Atom 1.8.0 in Windows.
I tried to run your last regexp in it.
(Very difficult for me to run coffee-script in Atom. I hacked character-count package.)
And it match with multi-line string.
m[0] = '/'.
file: .atom/.apm/character-count/lib/character-count.coffee
module.exports =
count: ->
m = "/\n\n\n/".match(/((/))(?=[^\/]*/)/)
alert(m[0])
activate: (state) ->
atom.commands.add 'atom-workspace', 'character-count:count', => @count()
from oniguruma.
π @kkos.
I also tried /[^/]*/
in the find-and-replace (to find slashes in ) with regex, it worked. But in the grammar file of a language package, no luck; even /\n*/
doesn't work, no idea why.
To minimize the possibilities why this doesn't work, I wrote a grammar file from scratch, this is the only rule in the grammar:
When the slashes are in the same line, it matches (see the scopes at cursor):
But if put newlines in between, it doesn't (see the scopes at cursor and the change of color):
It looks like a pattern in the grammar file doesn't search across linesβif it can't find a match in a line, it just starts fresh in the next line.
from oniguruma.
Found the answer in TextMate's manual which Atom's grammars are based on:
Note that the regular expressions are matched against only a single line of the document at a time. That means it is not possible to use a pattern that matches multiple lines. The reason for this is technical: being able to restart the parser at an arbitrary line and having to re-parse only the minimal number of lines affected by an edit. In most situations, it is possible to use the begin/end model to overcome this limitation.
Thanks for your time, really really appreciate it π
from oniguruma.
I thank for your investigation.
from oniguruma.
Related Issues (20)
- add oniguruma-devel to centos8.0+ HOT 2
- Dynamic library generated failed to support "(?-i)" HOT 3
- oniguruma not able to installed on PPC64le architecture HOT 3
- `.{0,99}` and `.*` behave differently on short input HOT 2
- mbc_enc_len(const UChar* p) to be improved HOT 4
- Does Oniguruma support POSIX collating symbols or equivalence classes? HOT 1
- New version?π€ HOT 1
- Does "retry-limit-in-match over" mean NOT MATCH? HOT 23
- ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS not working for ^* pattern HOT 1
- Literal escaped braces HOT 2
- what is escape code for `.` (literal dot)? HOT 1
- onig_match() can return wrong results with lookbehind at the end of the string HOT 2
- ONIG_SYNTAX_EMACS doesn't support "shy groups"
- With ONIG_SYNTAX_DEFAULT pattern '(?s)ABC' fails with 'undefined group option'. HOT 12
- Error 'unmatched range specifier in char-class' with hyphen in character class. HOT 1
- typos HOT 1
- :alpha: character class matches "non-letter" unicode characters. HOT 4
- Sample pattern and content to trigger error in onig_search? HOT 2
- Invalid utf8 sequence matches the pattern while it probably should not. HOT 1
- Test files ( 'e' function )
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oniguruma.