So I have a lot of text in a text file that acts like a "database" and I need to extract a specific part that starts from a string and ends with another one.
To be more specific, some of the "database" looks like this:
i:24;s:5:"sName";s:12:"adsfasdffdfd";s:7:"iStatus";i:1;s:9:"iPosition";i:0;s:17:"sDescriptionShort";s:29:"<p>test short description</p>";s:16:"sDescriptionFull";s:28:"<p>test full description</p>";
<p>test short description</p>
So you're looking for text that comes after the literals
i:24? Since none of these are special characters, let's begin our pattern construction with that literal sequence...
Next there may or may not be more characters to consume between the
i:24 and the opening
<p> tag. Let's assume that these characters can be anything, so we'll use a wildcard metacharacter with the
* giving us...
We want to tame the regex engine's appetite so let's modify our quantifier by making it non-greedy.
Next we want to match AND CAPTURE an opening,
...and the content inside of the
<p> tag, which we'll assume can be anything (read wildcard) and maybe nothing,
Remember to tame our
* quantifier's appetite so that it doesn't consume too many
And finally we'll close it off by consuming and capturing the closing
</p> tag, with the escaped forward-slash, since it's a special character.
Hope this works for what you're trying to accomplish.