婷婷久久综合九色综合,欧美成色婷婷在线观看视频,偷窥视频一区,欧美日本一道道一区二区

<tt id="bu9ss"></tt>
  • <span id="bu9ss"></span>
  • <pre id="bu9ss"><tt id="bu9ss"></tt></pre>
    <label id="bu9ss"></label>

    當(dāng)前位置:首頁(yè) >  站長(zhǎng) >  數(shù)據(jù)庫(kù) >  正文

    PostGreSql 判斷字符串中是否有中文的案例

     2021-05-03 16:06  來(lái)源: 腳本之家   我來(lái)投稿 撤稿糾錯(cuò)

      阿里云優(yōu)惠券 先領(lǐng)券再下單

    這篇文章主要介紹了PostGreSql 判斷字符串中是否有中文的案例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧。

    我就廢話不多說(shuō)了,大家還是直接看代碼吧~

    實(shí)例

    imos=# select 'hello' ~ '[\u2e80-\ua4cf]|[\uf900-\ufaff]|[\ufe30-\ufe4f]';
     ?column?
    ----------
     f
    (1 row)
    imos=#
    imos=# select 'hello中國(guó)' ~ '[\u2e80-\ua4cf]|[\uf900-\ufaff]|[\ufe30-\ufe4f]';
     ?column?
    ----------
     t
    (1 row)

     

    補(bǔ)充:PostgreSQL 判斷字符串包含的幾種方法

    判斷字符串包含的幾種方法:

    1. position(substring in string):

    postgres=# select strpos('abcd','aa');
     strpos
    --------
     0
    (1 row)
    postgres=# select strpos('abcd','ab');
     strpos
    --------
     1
    (1 row)
    postgres=# select strpos('abcdab','ab');
     strpos
    --------
     1
    (1 row)

    可以看出,如果包含目標(biāo)字符串,會(huì)返回目標(biāo)字符串笫一次出現(xiàn)的位置,可以根據(jù)返回值是否大于0來(lái)判斷是否包含目標(biāo)字符串。

    2. strpos(string, substring):

    該函數(shù)的作用是聲明子串的位置。

    postgres=# select 'abcd' ~ 'aa';
     ?column?
    ----------
     f
    (1 row)
    postgres=# select 'abcd' ~ 'ab';
     ?column?
    ----------
     t
    (1 row)
    postgres=# select 'abcdab' ~ 'ab';
     ?column?
    ----------
     t
    (1 row)

    作用與position函數(shù)一致。

    3. 使用正則表達(dá)式:

    postgres=# select 'abcd' ~ 'aa';
     ?column?
    ----------
     f
    (1 row)
    postgres=# select 'abcd' ~ 'ab';
     ?column?
    ----------
     t
    (1 row)
    postgres=# select 'abcdab' ~ 'ab';
     ?column?
    ----------
     t
    (1 row)

    4. 使用數(shù)組的@>操作符(不能準(zhǔn)確判斷是否包含):

    postgres=# select regexp_split_to_array('abcd','') @> array['b','e'];
     ?column?
    ----------
     f
    (1 row)
    postgres=# select regexp_split_to_array('abcd','') @> array['a','b'];
     ?column?
    ----------
     t
    (1 row)

    注意下面這些例子:

    postgres=# select regexp_split_to_array('abcd','') @> array['a','a'];
     ?column?
    ----------
     t
    (1 row)
    postgres=# select regexp_split_to_array('abcd','') @> array['a','c'];
     ?column?
    ----------
     t
    (1 row)
    postgres=# select regexp_split_to_array('abcd','') @> array['a','c','a','c'];
     ?column?
    ----------
     t
    (1 row)

    可以看出,數(shù)組的包含操作符判斷的時(shí)候不管順序、重復(fù),只要包含了就返回true,在真正使用的時(shí)候注意。

    文章來(lái)源:腳本之家

    來(lái)源地址:https://www.jb51.net/article/205193.htm

    申請(qǐng)創(chuàng)業(yè)報(bào)道,分享創(chuàng)業(yè)好點(diǎn)子。點(diǎn)擊此處,共同探討創(chuàng)業(yè)新機(jī)遇!

    相關(guān)文章

    熱門(mén)排行

    信息推薦