question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Full regex support in lookaheads (or at least \n and \s)

See original GitHub issue

Sometimes, for the sake of formatting my code to look nice, I like to add a new line immediately after the template literal tick. For example:

const test = await client.query(`
  select * from test
`)

Obviously this simple example does not need the new line (or I could have escaped before the tick), but larger queries often do to maintain alignment. No matter what I try, I cannot get the lookahead to match the whitespace because \s results in a JSCustom error “invalid escape character” .

I have tried "[\n\t ]*select" which will happily match spaces and tabs, but not the new line.

Also, your example in the config settings select\b does not match a template string select 1 from dual.

I find it strange that some regex works, but others don’t. Personally, whitespace matching would solve my problem, but it seems sensible to parse all valid regex.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Thom1729commented, Mar 6, 2022

There’s an easy way: in your Package Control settings, add:

"install_prereleases": [ "JSCustom"]

Or add "JSCustom" to the array if it already exists.

1reaction
nianiamcommented, Mar 4, 2022

Sorry for the slow reply and excuse my ignorance, but I’m not sure how to install the beta.

What I am doing:

  1. Download the beta release .zip and renaming the file extension to .sublime-package
  2. Use the command palette to Browse Packages
  3. Replace the regular install with the beta in the Installed Packages folder.

This doesn’t seem to change anything, the packages shows without a version and description if I list packages and it refuses to open the settings. Obviously I am doing something wrong here, but I am not sure what.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lookahead and Lookbehind Zero-Length Assertions
The bad news is that most regex flavors do not allow you to use just any regex inside a lookbehind, because they cannot...
Read more >
Lookahead and Lookbehind Tutorial—Tips &Tricks - RexEgg
Regex Lookahead and Lookbehind Tutorial. Explains the fine details of Lookahead and Lookbehind, including zero-width matches, overlapping matches and ...
Read more >
lookaround - Regex lookahead, lookbehind and atomic groups
An atomic group exits a group and throws away alternative patterns after the first matched pattern inside the group (backtracking is disabled).
Read more >
Lookahead and lookbehind - The Modern JavaScript Tutorial
When we look for X(?=Y) , the regular expression engine finds X and then ... Please Note: Lookbehind is not supported in non-V8...
Read more >
Regular Expression (Regex) Tutorial
Regex is supported in all the scripting languages (such as Perl, Python, PHP, ... 0, } print "\n"; # Try substitute s/regex/replacement/modifiers $inStr ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found