Skip to content

add functions for retrieving a Regex's source and flags #5

@michaelficarra

Description

@michaelficarra

Should the flags be exposed as a record or as some canonicalised string? Either way, should there be a function for converting between the two formats?

edit: JS RegExp flags can be retrieved as a string like this:

function flags(re) {
  var s = '' + re;
  return s.slice(s.lastIndexOf('/') + 1);
}

or as a record like this:

function flags(re) {
  return {
    multiline: re.multiline,
    ignoreCase: re.ignoreCase,
    global: re.global,
    sticky: !!re.sticky,
    unicode: !!re.unicode
  };
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions