preg-split

    2熱度

    1回答

    我需要從字符串中提取2個部分,並將它們放入數組中。 $test = "add_image_1"; 我需要確保此字符串以「add_image」開始,以「_1」結尾但只能存儲在最後的數字部分。我想使用preg_split作爲學習經驗,因爲我將來需要使用它。 我不知道如何使用這個功能來找到一個確切的詞(我嘗試使用「\ b」和故障),我用「\ w +」來代替: $result = preg_split

    1熱度

    2回答

    我試着在preg_split後面加上一個單詞和一個冒號。 這對我來說,如果我一個單詞後的Split Works: $split = preg_split('/\b(\w*WORD\w*)\b/', $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); 現在我正在尋找的東西分裂AFER我的話+冒號。 Like Car:

    0熱度

    2回答

    我有以下從輸入後textarea的字符串: ' 123 '123 '' 123 ''123 `123 ` 123 我想將它轉化成下面的數組: [0] => 123 [1] => 123 [2] => 123 [3] => 123 [4] => 123 [5] => 123 [6] => 123 我我試着用這個,但我不知道如何將它們全部結合在一個正則表達式中: \ ('

    0熱度

    1回答

    對於某些數據處理,我需要將一個字符串拆分爲多個項目。 的輸入字符串的例子是: 'one, two & three and four-five 123-456' 現在,我需要這個串分離成的物品,在可能情況下定界符是,,&,(空間),and,-。但是,這是我卡住的地方,它不應該分裂在-之間,當它在兩個數字之間。 我使用PHP和preg_split做實際的分裂,但我需要一個正則表達式匹配的分隔符除所

    0熱度

    1回答

    我在PHP中使用preg_split函數將段落拆分爲幾個句子。 在我的情況: $str = 'Applicants can check the final result of Admissions through the online enquiry system. The online enquiry system will be available from 10:00 a.m. on Nov

    0熱度

    2回答

    我有一個字符串"/test:n(0-2)/div/",我想通過正則表達式分割成一個數組與功能preg_split()。輸出應該是這樣的: output = { [0]=>"test:n(0-2)" [1]=>"div" } 然而,它似乎並不像我想的那麼容易。以下是我的嘗試:https://regex101.com/r/iP2lD8/1 我在做什麼錯?

    0熱度

    1回答

    我期待將一個段落分解成句子,然後轉換爲'分解'字符串,但需要將標點作爲數組的元素。 示例文本: $meta = 'I am looking to break this paragraph into chunks. I have researched, tried and tested various combinations; however, I cannot seem

    0熱度

    2回答

    我試圖使用像R401.4或R402.3.4分隔符使用下面的代碼,以分割一個大的字符串: <?php $chapter = "http://codes.iccsafe.org/app/book/content/2015-I-Codes/2015%20IRC%20HTML/Chapter%204.html"; $data = file_get_contents($chapter)

    4熱度

    3回答

    我嘗試拆分字符串A1B22C333以獲取數組[0] => A1,[1] => B22,[2] => C333。這是我的失敗嘗試: $mystring = "A1B22C333"; $pattern = "[\w\d+]"; $arr = preg_split("/".$pattern."/", $mystring); print_r($arr); ,但我得到: Array ([0] =>

    0熱度

    2回答

    我正在使用preg_split將字符串拆分爲單詞。 但是,它不適用於從mysql文本列中提取的特定字符串。 如果我手動將字符串分配給一個變量,它將正常工作,但不是從數據庫中提取字符串時。 下面是簡單的代碼我使用: //The failing string. When manually assigned like this it works correctly $string = "<p><st