-5

I have a text link

Yeast-Aid™ 200c - Hypoallergenic

I want to replace "200c" with "200 Caps" as this will be done on 20K records i want and expression to be able to replace any "c" prefixed by number with " Caps".

I use PHP.

Ravish Kumar
  • 602
  • 1
  • 8
  • 20
  • 2
    That's easy. Did you attempt anything? * See also [Open source RegexBuddy alternatives](http://stackoverflow.com/questions/89718/is-there) and [Online regex testing](http://stackoverflow.com/questions/32282/regex-testing) for some helpful tools, or [RegExp.info](http://regular-expressions.info/) for a nicer tutorial. – mario Feb 13 '13 at 00:17

1 Answers1

2

This is very basic regex substitution. Try this program out:

<?php
$string = 'Yeasties 200c - Hyperhyperhyper';
echo preg_replace('/(\d)c/i', '$1 Caps', $string);
echo "\n";
?>

preg_replace preforms the regex substitution.

If you cannot figure out how that program works, or want a reference, try the php documentation here, preg_replace.

You really should look online for documentation first. I have never used php before (literally this is my first program with it), but I didn't find it to challenging. Perhaps the most important coding skill is being able to learn things quickly.

Sudo Bash
  • 373
  • 5
  • 14