zhangshaohan

PostgreSQL 用正则表达式对字符串进行截取的方法

  •  
  •   zhangshaohan · Mar 19, 2020 · 4850 views
    This topic created in 2247 days ago, the information mentioned may be changed or developed.

    请教各位大佬们,PG 怎么从一个字符串中截取一个特定类型的字符串呢?原字符串是任意的,字符串里包含一个字母 A 开头,然后后面跟十个数字,需要把这个截取出来。比如字符串为:阿萨框架获得撒阿斯达 A3829232472 家快捷键。截取出来的为:A3829232472

    2 replies    2020-03-20 10:17:45 +08:00
    cookii
        1
    cookii  
       Mar 19, 2020
    select regexp_replace(str,'.*(A\d{10}).*','\1','g')
    zhangshaohan
        2
    zhangshaohan  
    OP
       Mar 20, 2020
    @imzhoukunqiang 太强了,感谢大佬!!!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   954 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 79ms · UTC 20:08 · PVG 04:08 · LAX 13:08 · JFK 16:08
    ♥ Do have faith in what you're doing.