General Settings
Regex Settings
Initializing editor, please stand by...
Loading content, please hold...
You seem to be using an outdated version of your browser which is no longer supported by It is highly recommended that you upgrade your browser. Sorry for the inconvenience.
Status: Fetching debug info...
collapse all
Please hold while we fetch the debug data. This might take some time.

I have a code snippet written in PHP that pulls a block of text from a database and sends it out to a widget on a webpage. The original block of text can be a lengthy article or a short sentence orrrr two; but for this widget I can't display more than, say, 200 characters. I could use substr() to chop off the text at 200 chars, but the result would be cutting off in the middle of words-- what I really want is to chop the text at the end of the last word before 200 chars.

Create test
given the string
assert that
Test list
An explanation of your regex will be automatically generated as you type.
Match information
Detailed match information will be displayed here automatically.
Quick reference