Regular expression to extract road labels from OSM other_tags ref Planned maintenance...

Is there a service that would inform me whenever a new direct route is scheduled from a given airport?

How widely used is the term Treppenwitz? Is it something that most Germans know?

"Seemed to had" is it correct?

Letter Boxed validator

How can I make names more distinctive without making them longer?

Gastric acid as a weapon

I need to find the potential function of a vector field.

What LEGO pieces have "real-world" functionality?

I am not a queen, who am I?

Is 1 ppb equal to 1 μg/kg?

How much radiation do nuclear physics experiments expose researchers to nowadays?

Are my PIs rude or am I just being too sensitive?

ListPlot join points by nearest neighbor rather than order

Antler Helmet: Can it work?

If a contract sometimes uses the wrong name, is it still valid?

Is the address of a local variable a constexpr?

How to deal with a team lead who never gives me credit?

When to stop saving and start investing?

Bonus calculation: Am I making a mountain out of a molehill?

Stars Make Stars

What would be the ideal power source for a cybernetic eye?

Why was the term "discrete" used in discrete logarithm?

Can a non-EU citizen traveling with me come with me through the EU passport line?

List *all* the tuples!



Regular expression to extract road labels from OSM other_tags ref



Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Regular expression substring for labellingHow to extract a single road from OSM GIS Database?OSM line labels in TilemillData Reviewer Regular Expression for HHMM time formatExtract large area from OSMRegular expression substring for labellingWhat regular expression engine does QGIS use?Extract addresses from osm fileUsing substring for labeling in QGIS?ArcGIS Data Reviewer Regular expression to limit the number of characters (Text Length) in a fieldExtract data from OSM url using QGIS





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







2















Extended question to the issue: Regular expression substring for labelling



The answers I've found on the link above were fine for "simple" road labels.



Unfortunately, I don't have a big SQL-knowledge, therefore, I would like to extend Erik's question.
How can we extract other road labels (alphanumeric) from the OSM lines layer "other_tags" between the ("ref"=>") and the last (")?



Examples:




  1. "ref"=>"AP 520" -> AP 520

  2. "ref"=>"M123-4" -> M123-4

  3. "ref"=>"EN 13-5" -> EN 13-5

  4. "ref"=>"AG-52" -> AG-52


In order to avoid to write thousands of different expressions depending on each example, isn't any expression that extracts the content only of "ref"=>"xxxxxxxx"?



I tried everything using the "regexp_substr".










share|improve this question

























  • Can you post how the tag looks in the database. I would like to see how the quotation marks work in it. If you had a string String = ''' "ref"=>"AP 520" ''' and you wanted to only get 'AP 520' you would do , NewString = String.split(' " ')[-2] , that would give you 'AP 520' for the NewString.

    – ed.hank
    Dec 27 '17 at 20:50


















2















Extended question to the issue: Regular expression substring for labelling



The answers I've found on the link above were fine for "simple" road labels.



Unfortunately, I don't have a big SQL-knowledge, therefore, I would like to extend Erik's question.
How can we extract other road labels (alphanumeric) from the OSM lines layer "other_tags" between the ("ref"=>") and the last (")?



Examples:




  1. "ref"=>"AP 520" -> AP 520

  2. "ref"=>"M123-4" -> M123-4

  3. "ref"=>"EN 13-5" -> EN 13-5

  4. "ref"=>"AG-52" -> AG-52


In order to avoid to write thousands of different expressions depending on each example, isn't any expression that extracts the content only of "ref"=>"xxxxxxxx"?



I tried everything using the "regexp_substr".










share|improve this question

























  • Can you post how the tag looks in the database. I would like to see how the quotation marks work in it. If you had a string String = ''' "ref"=>"AP 520" ''' and you wanted to only get 'AP 520' you would do , NewString = String.split(' " ')[-2] , that would give you 'AP 520' for the NewString.

    – ed.hank
    Dec 27 '17 at 20:50














2












2








2








Extended question to the issue: Regular expression substring for labelling



The answers I've found on the link above were fine for "simple" road labels.



Unfortunately, I don't have a big SQL-knowledge, therefore, I would like to extend Erik's question.
How can we extract other road labels (alphanumeric) from the OSM lines layer "other_tags" between the ("ref"=>") and the last (")?



Examples:




  1. "ref"=>"AP 520" -> AP 520

  2. "ref"=>"M123-4" -> M123-4

  3. "ref"=>"EN 13-5" -> EN 13-5

  4. "ref"=>"AG-52" -> AG-52


In order to avoid to write thousands of different expressions depending on each example, isn't any expression that extracts the content only of "ref"=>"xxxxxxxx"?



I tried everything using the "regexp_substr".










share|improve this question
















Extended question to the issue: Regular expression substring for labelling



The answers I've found on the link above were fine for "simple" road labels.



Unfortunately, I don't have a big SQL-knowledge, therefore, I would like to extend Erik's question.
How can we extract other road labels (alphanumeric) from the OSM lines layer "other_tags" between the ("ref"=>") and the last (")?



Examples:




  1. "ref"=>"AP 520" -> AP 520

  2. "ref"=>"M123-4" -> M123-4

  3. "ref"=>"EN 13-5" -> EN 13-5

  4. "ref"=>"AG-52" -> AG-52


In order to avoid to write thousands of different expressions depending on each example, isn't any expression that extracts the content only of "ref"=>"xxxxxxxx"?



I tried everything using the "regexp_substr".







qgis openstreetmap labeling regular-expression






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 7 '18 at 10:50









underdark

69.2k13178349




69.2k13178349










asked Dec 27 '17 at 19:18









Filipe TabordaFilipe Taborda

112




112













  • Can you post how the tag looks in the database. I would like to see how the quotation marks work in it. If you had a string String = ''' "ref"=>"AP 520" ''' and you wanted to only get 'AP 520' you would do , NewString = String.split(' " ')[-2] , that would give you 'AP 520' for the NewString.

    – ed.hank
    Dec 27 '17 at 20:50



















  • Can you post how the tag looks in the database. I would like to see how the quotation marks work in it. If you had a string String = ''' "ref"=>"AP 520" ''' and you wanted to only get 'AP 520' you would do , NewString = String.split(' " ')[-2] , that would give you 'AP 520' for the NewString.

    – ed.hank
    Dec 27 '17 at 20:50

















Can you post how the tag looks in the database. I would like to see how the quotation marks work in it. If you had a string String = ''' "ref"=>"AP 520" ''' and you wanted to only get 'AP 520' you would do , NewString = String.split(' " ')[-2] , that would give you 'AP 520' for the NewString.

– ed.hank
Dec 27 '17 at 20:50





Can you post how the tag looks in the database. I would like to see how the quotation marks work in it. If you had a string String = ''' "ref"=>"AP 520" ''' and you wanted to only get 'AP 520' you would do , NewString = String.split(' " ')[-2] , that would give you 'AP 520' for the NewString.

– ed.hank
Dec 27 '17 at 20:50










3 Answers
3






active

oldest

votes


















1














Try the following:



regexp_substr("other_tags",'"ref"=>"([\w- ]+)')


Should work assuming you have no other kinds of whitespaces, or unusual symbols/letters in the ref field.



It looks for "ref"=> then matches any word characters (A-Z, a-z, 0-9, underscore) as well as dash and space ([A-Za-z0-9-_ ]) and continues doing so (+) until it stops matching (in this case when it hits the double quotation mark).






share|improve this answer

































    0














    You can open your OSM file with the QuickOSM plugin. It will split your "other_tags" into fields automatically.
    If the process is too slow, you can provide a custom OSM Conf file to get the field you want in QuickOSM, "Open OSM file" tab.






    share|improve this answer































      0














      This one worked for me:



      regexp_substr( "other_tags", '\"ref"=>"(.*?)\"')




      share








      New contributor




      Pierre HARDY is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





















        Your Answer








        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "79"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: false,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f266423%2fregular-expression-to-extract-road-labels-from-osm-other-tags-ref%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        1














        Try the following:



        regexp_substr("other_tags",'"ref"=>"([\w- ]+)')


        Should work assuming you have no other kinds of whitespaces, or unusual symbols/letters in the ref field.



        It looks for "ref"=> then matches any word characters (A-Z, a-z, 0-9, underscore) as well as dash and space ([A-Za-z0-9-_ ]) and continues doing so (+) until it stops matching (in this case when it hits the double quotation mark).






        share|improve this answer






























          1














          Try the following:



          regexp_substr("other_tags",'"ref"=>"([\w- ]+)')


          Should work assuming you have no other kinds of whitespaces, or unusual symbols/letters in the ref field.



          It looks for "ref"=> then matches any word characters (A-Z, a-z, 0-9, underscore) as well as dash and space ([A-Za-z0-9-_ ]) and continues doing so (+) until it stops matching (in this case when it hits the double quotation mark).






          share|improve this answer




























            1












            1








            1







            Try the following:



            regexp_substr("other_tags",'"ref"=>"([\w- ]+)')


            Should work assuming you have no other kinds of whitespaces, or unusual symbols/letters in the ref field.



            It looks for "ref"=> then matches any word characters (A-Z, a-z, 0-9, underscore) as well as dash and space ([A-Za-z0-9-_ ]) and continues doing so (+) until it stops matching (in this case when it hits the double quotation mark).






            share|improve this answer















            Try the following:



            regexp_substr("other_tags",'"ref"=>"([\w- ]+)')


            Should work assuming you have no other kinds of whitespaces, or unusual symbols/letters in the ref field.



            It looks for "ref"=> then matches any word characters (A-Z, a-z, 0-9, underscore) as well as dash and space ([A-Za-z0-9-_ ]) and continues doing so (+) until it stops matching (in this case when it hits the double quotation mark).







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Dec 30 '17 at 10:01

























            answered Dec 30 '17 at 9:30









            she_weedsshe_weeds

            1,464316




            1,464316

























                0














                You can open your OSM file with the QuickOSM plugin. It will split your "other_tags" into fields automatically.
                If the process is too slow, you can provide a custom OSM Conf file to get the field you want in QuickOSM, "Open OSM file" tab.






                share|improve this answer




























                  0














                  You can open your OSM file with the QuickOSM plugin. It will split your "other_tags" into fields automatically.
                  If the process is too slow, you can provide a custom OSM Conf file to get the field you want in QuickOSM, "Open OSM file" tab.






                  share|improve this answer


























                    0












                    0








                    0







                    You can open your OSM file with the QuickOSM plugin. It will split your "other_tags" into fields automatically.
                    If the process is too slow, you can provide a custom OSM Conf file to get the field you want in QuickOSM, "Open OSM file" tab.






                    share|improve this answer













                    You can open your OSM file with the QuickOSM plugin. It will split your "other_tags" into fields automatically.
                    If the process is too slow, you can provide a custom OSM Conf file to get the field you want in QuickOSM, "Open OSM file" tab.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Apr 4 '18 at 6:37









                    etrimailleetrimaille

                    1,943620




                    1,943620























                        0














                        This one worked for me:



                        regexp_substr( "other_tags", '\"ref"=>"(.*?)\"')




                        share








                        New contributor




                        Pierre HARDY is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.

























                          0














                          This one worked for me:



                          regexp_substr( "other_tags", '\"ref"=>"(.*?)\"')




                          share








                          New contributor




                          Pierre HARDY is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.























                            0












                            0








                            0







                            This one worked for me:



                            regexp_substr( "other_tags", '\"ref"=>"(.*?)\"')




                            share








                            New contributor




                            Pierre HARDY is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.










                            This one worked for me:



                            regexp_substr( "other_tags", '\"ref"=>"(.*?)\"')





                            share








                            New contributor




                            Pierre HARDY is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.








                            share


                            share






                            New contributor




                            Pierre HARDY is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.









                            answered 3 mins ago









                            Pierre HARDYPierre HARDY

                            1




                            1




                            New contributor




                            Pierre HARDY is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.





                            New contributor





                            Pierre HARDY is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.






                            Pierre HARDY is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f266423%2fregular-expression-to-extract-road-labels-from-osm-other-tags-ref%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Щит и меч (фильм) Содержание Названия серий | Сюжет |...

                                Венесуэла на летних Олимпийских играх 2000 Содержание Состав...

                                Meter-Bus Содержание Параметры шины | Стандартизация |...