Function List for UDL - multi-line regex
-
I’ve noticed that many of the predefined Function List languages have large multi-line regex. I have tried to do the same in my UDLs, but it doesn’t work.
I can literally take a regex that works in capturing a class/function, add a line break (CRLF) and it simply doesn’t work anymore. Having said that, I’m also not sure if the
# comments
that I see in the pre-defined Function List langs works at all in the UDLs. I’ve tried it, but it seems to make no difference, with or without.Is it possible to use multi-line regex in Function List for UDLs?
I’m using v8.4.6, but I’m sure this affects other versions as well.
-
@Jeb-Dude said in Function List for UDL - multi-line regex:
Is it possible to use multi-line regex in Function List for UDLs?
According to this post, no, not even any regex.
Terry
PS also read the online manual for more background on UDL, here.
-
Thanks for the reply. This is not actually the UDL itself. It is the Function List as it is applied to the UDL in xml files (within the
functionList
folder). The regex works for my UDL, and I can have the function list populate functions and classes as expected.I just can’t seem to use multi-line regex (breaking up a long complex pattern across multiple lines). This “multi-line” regex is used in Function List xml files for predefined languages.
-
You mean
(?x)
in the regex, to allow splitting the regex across multiple lines in the function list XML file? Yes, that’s allowed, as seen in many of the function list definitions distributed with Notepad++. You can use that syntax in any function list definition, whether it’s for a builtin lexer language or a UDL.You probably have a mistake in the conversion from single-line to multi-line: my guess is that when you created the multi-line version, you still expected it to match a space when you typed a space. Since
(?x)
actually means “Ignore non-escaped whitespace in regex”*, not “allow mulitiline”, if you want to match a space or newline inside that regex, you need to encode it appropriately as\h
(any horizontal whitespace, including ASCII 32 space and TAB) or\r\n
(windows CRLF) or similar, or\x20
to get only the ASCII 32 space.But since you don’t show us anything, we cannot actually say for sure what you’ve done wrong.
-
Thanks! My apologies. I should have read the regular expressions help
more carefully. I see it now.Thanks again!
EDIT: Just wanted to add that you nailed the issue I was having almost exactly. Except that I didn’t even realize
(?x)
existed as an option. Once I realized that, I found it in the docs immediately and understood what I needed to do. -
Hello, @Jeb-dude, @peterjones, @terry-r and All,
To @jeb-dude :
Refer to the end of the post below (
Notes
section ) for some explanations regarding the free-spacing mode(?x)
:https://community.notepad-plus-plus.org/post/81368
To @peterjones :
These explanations, regarding the
(?x)
mode, could be added to theOfficial N++ Documentation
, if you’ll find some spare time ;-))Best Regards,
guy038
-
If I’m not mistaken, it is in the docs, but it’s under the “Searching” page, and there is no explicit link mentioned in the “Function List” page to check out the “Searching” page.
In my opinion, that would suffice. I just wasn’t aware that the “Searching” section applied to the config files for “Function List” stuff.
-
That’s because that entire page pertains to the Regex aspect. If you notice there are links on both sides of the page in the browser. The ones on the left are main links, the ones on the right are the sectional links in that subject…and because it’s an extensive subject, it’s broken down into many sections. By the way, why learn Regex, if you’re not searching? :) It just stands to reason that, that is what you’re using Regex for. :)
-
Of course, I realized that after @PeterJones posted his answer.