# Extract content using preg\_match

**URL:** <https://www.phphelp.com/t/extract-content-using-preg-match/31271>\
**Category:** Beginners - Learning PHP\
**Created:** [March 14, 2020, 11:52am UTC](https://www.phphelp.com/t/extract-content-using-preg-match/31271 "2020-03-14T11:52:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Moutamared](https://www.phphelp.com/letter_avatar_proxy/v4/letter/m/c37758/32.png) [@Moutamared](https://www.phphelp.com/u/Moutamared)\
**Post date:** [March 14, 2020, 11:52am UTC](https://www.phphelp.com/t/extract-content-using-preg-match/31271/1 "2020-03-14T11:52:15Z")

</div>

hello  
i have problem with preg\_match, i couldn’t extract a specific content from a certain line  
for example, i have the following line :

```
"ch Aabcd+3 abc - anything (412ms) OK \

```

i want to extract the content between : `"ch` and `OK \`  
i have tried this but it doesn’t extract the content as mentioned above

```
preg_match('(/"ch[^.]?([A-Za-z0-9- ()+]+)[]+$/) (/OK/)/s', $line, $sv_content)

```

can you help me please ?

---

<div class="post-metadata">

**Author:** ![frankbeen](https://www.phphelp.com/letter_avatar_proxy/v4/letter/f/f1d935/32.png) [@frankbeen](https://www.phphelp.com/u/frankbeen)\
**Post date:** [March 14, 2020, 7:03pm UTC](https://www.phphelp.com/t/extract-content-using-preg-match/31271/2 "2020-03-14T19:03:55Z")

</div>

Does this work for you?

```auto
echo substr($line, 4, -5);

```

---

<div class="post-metadata">

**Author:** ![Moutamared](https://www.phphelp.com/letter_avatar_proxy/v4/letter/m/c37758/32.png) [@Moutamared](https://www.phphelp.com/u/Moutamared)\
**Post date:** [March 14, 2020, 10:28pm UTC](https://www.phphelp.com/t/extract-content-using-preg-match/31271/4 "2020-03-14T22:28:42Z")

</div>

yes, it does work  
thank you so much
