久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

獲取引號中的文本

Get text in quotes(獲取引號中的文本)
本文介紹了獲取引號中的文本的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

是否有一些函數可以只從變量的引號中獲取文本?
就像:

is there is some function that can take just text inside the quotes from the variable?
Just like:

$text = 'I am "pro"';
echo just_text_in_quotes($text);

我知道這個功能不存在..但我需要類似的東西.我在想 fnmatch("*",$text)但是這不能只回顯那個文本,它只是為了檢查.你能幫我么?謝謝.

I know that this function doesn't exist.. but I need something like that. I was thinking about fnmatch("*",$text) But this cant Echo just that text, It's just for check. Can you please help me? Thank you.

推薦答案

此函數將返回引號之間的第一個匹配文本(可能是一個空字符串).

This function will return the first matched text between quotes (possibly an empty string).

function just_text_in_quotes($str) {
   preg_match('/"(.*?)"/', $str, $matches);
   return isset($matches[1]) ? $matches[1] : FALSE;
}

您可以修改它以返回所有匹配項的數組,但在您的示例中,您在 echo 返回值的上下文中使用它.如果它返回一個數組,你將得到的只是 Array.

You could modify it to return an array of all matches, but in your example you use it within the context of echoing its returned value. Had it returned an array, all you would get is Array.

您最好編寫一個可以處理多次出現和自定義分隔符的更通用的函數.

You may be better off writing a more generic function that can handle multiple occurrences and a custom delimiter.

function get_delimited($str, $delimiter='"') {
    $escapedDelimiter = preg_quote($delimiter, '/');
    if (preg_match_all('/' . $escapedDelimiter . '(.*?)' . $escapedDelimiter . '/s', $str, $matches)) {
        return $matches[1];
    }
}

如果沒有找到匹配項,這將返回 null.

This will return null if no matches were found.

這篇關于獲取引號中的文本的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Add programmatically a downloadable file to Woocommerce products(以編程方式將可下載文件添加到 Woocommerce 產品)
Get today#39;s total orders count for each product in Woocommerce(獲取今天 Woocommerce 中每種產品的總訂單數)
Add Custom registration fields in WooCommerce and phone field validation issue(在 WooCommerce 和電話字段驗證問題中添加自定義注冊字段)
Add a select field that will change price in Woocommerce simple products(在 Woocommerce 簡單產品中添加一個將更改價格的選擇字段)
Add custom columns to admin products list in WooCommerce 3(在 WooCommerce 3 中將自定義列添加到管理產品列表)
Customizing checkout quot;Place Orderquot; button output html(自定義結帳“下訂單按鈕輸出html)
主站蜘蛛池模板: 色综合一区二区 | 久久精品国产免费 | 一区二区在线不卡 | 第四色播日韩第一页 | 一级毛片视频在线 | 国产精品久久久久久久久久久久久 | 久久一区视频 | 国产精品91网站 | 国产精品久久久久久久久久久久 | 一本色道久久综合亚洲精品高清 | 奇米超碰在线 | 国产精品成人一区二区三区 | 国产美女福利在线观看 | 我要看黄色录像一级片 | 欧美一级做性受免费大片免费 | 亚洲视频在线免费观看 | 午夜在线视频 | 国产伦一区二区三区 | 亚洲免费视频播放 | 国产精品一区二区无线 | 国产乱码精品1区2区3区 | 国产高潮好爽受不了了夜夜做 | 亚洲视频免费在线播放 | 一级午夜aaa免费看三区 | 国产综合网站 | 一区二区三区成人 | 国产三级日本三级 | 久草免费在线视频 | 97精品国产97久久久久久免费 | 国产成人在线一区 | 亚洲少妇综合网 | 暴草美女 | 在线看av网址 | 91精品久久久久久久久中文字幕 | 国产一区二区三区在线免费观看 | 超碰在线97国产 | 久久免费视频在线 | 神马福利 | 在线色网| 爱爱免费视频 | 黄色免费在线观看网站 |