Link to home
Start Free TrialLog in
Avatar of hankknight
hankknightFlag for Canada

asked on

PHP/REGEX: Bullets if Line Starts with Dash

Using PHP and REGEX, how can I automatically convert dashes at the beginning of each line into bullets, providing there is exactly one space after the dash and the proceeding charactor is NOT a lowercase letter?


- Hello World
should become:
• Hello World

- 123 Testing
should become:
• 123 Testing

- this is a test
should not be changed.

Hello - World
should not be changed.
Avatar of kaufmed
kaufmed
Flag of United States of America image

Try:

$result = preg_replace('/^- (?![a-z])/', "• ", $input);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial