Skip to content

Add find-and-replace expression operator #4100

Open

Description

@lucaswoj

From @nickidlugash on August 3, 2015 23:46

Currently we can't make use of the way duplex shields in the mapbox streets data are designed to be styled, because we can't use regex as part of values, and we also don't accept \n as a space for line wrapping. Is it feasible to implement the ability to use find/replace and \n?

Copied from original issue: mapbox/mapbox-gl-style-spec#321

Activity

  1. lucaswoj commented on Feb 1, 2017

    @lucaswoj
    ContributorAuthor

    From @1ec5 on August 3, 2015 23:48

    The regex half of this is covered by #233.

  2. lucaswoj commented on Feb 1, 2017

    @lucaswoj
    ContributorAuthor

    From @jfirebaugh on August 4, 2015 0:53

    #233 is for the use of regexes in filters, which is a different use case.

    I seem to recall an issue for wrapping on newlines, but I can't find it at the moment.

  3. lucaswoj commented on Feb 1, 2017

    @lucaswoj
    ContributorAuthor

    We have a separate issue for regex support and have already implemented newline support.

  4. lucaswoj commented on Feb 1, 2017

    @lucaswoj
    ContributorAuthor

    From @jfirebaugh on December 22, 2016 18:25

    As noted above: the other issue is for regex support in filters. This is about regex support in functions.

  5. added
    cross-platform 📺
    on Feb 3, 2017
  6. 1ec5 commented on Oct 26, 2017

    @1ec5
    Contributor

    As of #5434, expressions (the successor to functions) can be used as filters. #4089 tracks adding an expression operator for testing whether a string matches a regular expression, but we can leave this issue open to track adding an expression operator for finding and replacing occurrences of a substring or regular expression match within a given string.

  7. changed the title [-]Allow use of find/replace regex to compute property values[/-] [+]Add find-and-replace expression operator[/+] on Oct 26, 2017
  8. stevage commented on Jan 21, 2024

    @stevage
    Contributor

    Currently you can kind of workaround find-and-replace without regex, but it's pretty clunky:

    ["match", ["index-of", "Mount", ["to-string", ["get", "name"]]], 0, ["concat", "Mt", ["slice", ["to-string", ["get", "name"]],5]],  ["to-string", ["get", "name"]]]
    

    This would certainly improve the ergonomics of that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    api 📝cross-platform 📺

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions