Questions tagged [rx]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2
votes
1answer
40 views

Trouble while using string-match with rx expression

I'm trying to write a function that takes a string and returns non-nil if it's the word do not followed by the character :. Something like this: (string-match (rx "do[^:]") input) but I get the ...
0
votes
1answer
43 views

`eval` in `rx-to-string` works in `*scratch*` but not in code

I am trying to code an rx-to-string form that contains an intermediate regexp. This code works in Lisp Interaction Mode: (let* ((a-plus '(one-or-more "a"))) (rx-to-string '(sequence (eval a-plus)))...
0
votes
1answer
26 views

Inline elements of variable list value in rx() macro call [duplicate]

Is there a more compact way to make use of the rx macro in cases where we want to inline a list of strings from a variable? Such as (defconst c++20-new-keywords-list (list "char8_t" "import" ...
0
votes
3answers
162 views

Highlight a comma-separated list by using rx macro

I want to create font locking for string like: interface Foo extends B, C, D, E {}; And I can't understand why my regexp rule doesn't work for font locking: (defvar my-font-lock-keywords `( ;;...
1
vote
2answers
131 views

Does rx macro work with underscore in character classes

I'm a little confused by the fact that underscore does not shown in the character class. ELISP> (require 'rx) rx ELISP> (rx (any "A-Z" "_")) "[A-Z_]" ELISP> (rx (any "A-z" "_")) "[A-z]" ...
7
votes
1answer
522 views

Is there any principal difference between “A-Z” and upper?

I just want to make sure I understood this correctly. (rx (one-or-more (any upper lower))) is equal to (rx (one-or-more (any "A-Z" "a-z"))) Correct?
1
vote
1answer
121 views

How to make rx.el regexps non greedy?

Here is my expression: (setq myregexp (rx bol "####" (one-or-more anything) ".")) This should match any string starting with "####", spanning ...
2
votes
2answers
201 views

Rx: Skip commented out lines

I'm trying to make an expression that would match the text foo if it's not on a commented out line. ;; foo ; <= not this bar ; <= not this foo ; <= this Now rx.el can exclude ...
0
votes
1answer
191 views

How to highlight other square brackets in custom major mode?

I'm working in a custom major mode, and part of the syntax are the square brackets, like [Hello world] and so they can contain nested square brackets as in [Hello [World]], however I see this problem ...
3
votes
2answers
510 views

How do I use not in rx-to-string?

I just started working with rx and was able to achieve the opposite of the regex I wanted: (rx-to-string `(: (or (: line-start (not ,comment-start)) (: line-start (zero-or-more whitespace) line-...
2
votes
1answer
190 views

How to use re-builder with rx special forms?

I opened re-builder and changed its syntax to "rx". My target buffer has plenty of digits and (rx (and "4")) highlights a lot of 4s, however, (rx (and digit)) is apparently valid but matches nothing ...
5
votes
4answers
267 views

Is there a way to search/replace with regexps interactively using rx syntax?

I really like rx but I can't use it interactively. Has someone already tried to extend isearch to support rx syntax?
4
votes
1answer
182 views

Regexp to parse Hy errors for Flycheck

I'm trying to write a Flycheck checker definition based on Hy, using the API here. As part of that, I have to define a pattern for error matching. Now, Hy gives quite a large error spew, for example: ...
15
votes
1answer
712 views

How do I create a dynamic regexp with rx?

I want to use rx to create regular expressions with runtime values. Currently, I'm doing this: (setq strings '("foo" "bar" "baz")) (eval `(rx symbol-start (or ,@strings) symbol-end)) However, I'd ...