Skip to content
Advertisement

Return a substring of a string if exists

I need to extract console platform from the description of products in CSV file.

I used regex to match all the console brands that are included in the list.

This is for WP All-Import plugin PHP editor widget.

JavaScript

I expect: XBOX-360

It returns the rest of the string except what I expect: NINTENDO MARIO KART 7 SPECIAL EDITION

Advertisement

Answer

You can use preg_match. The $ result [0] variable will be the result

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement