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.

Feature Request: Allow `regexmatch` on objects other than strings

See original GitHub issue

It would be very helpful to be able to run a regexmatch check on an array, for example.

I found an easier way around the problem I wanted to solve, but the general functionality would still be powerful.

regexmatch("^\d{3}$", [1, 22, 333, 4444]) would match 333. But this opens the question of when the whole test is true. Do all elements of the array have to match (&&) or just one (||). Perhaps this could be an argument to regexmatch(pattern, object, strictness)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
blacksmithgucommented, Mar 31, 2021

That’s right, it would return boolean[]; and yes.

1reaction
blacksmithgucommented, Mar 30, 2021

Yeah, I realized after your file.tags use-case that some better array support was needed. I have a slightly different idea for the implementation - I can make common methods like regexmatch “vectorized”, which means they return an array of results if the input is an array. Then, I can add the any() and all() methods, which check if any/every element in an array is true or false. You could then check if any string matches via

any(regexmatch(regex, [...])

and all strings via

all(regexmatch(regex, [...])

Read more comments on GitHub >

github_iconTop Results From Across the Web

re — Regular expression operations — Python 3.11.1 ...
Source code: Lib/re/ This module provides regular expression matching operations similar to those found in Perl. Both patterns and strings to be searched ......
Read more >
Regular Expression (Regex) Tutorial
Regular Expression, or regex or regexp in short, is extremely and amazingly powerful in searching and manipulating text strings, particularly in processing ...
Read more >
String.prototype.match() - JavaScript - MDN Web Docs
The match() method retrieves the result of matching a string against a regular expression.
Read more >
Best Practices for Regular Expressions in .NET - Microsoft Learn
Match (String, String). This method doesn't require instantiation of a regular expression object. You can instantiate a Regex object and call ...
Read more >
Regular Expressions :: Eloquent JavaScript
Other than that, the object looks like (and in fact is) an array of strings, whose first element is the string that was...
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