Search code examples
regexslash

regex forward slash alpha/numeric


Is it possible to parse a string and where ever there is an alpha on either side of a / drop the / and insert a space, but do not do it to numerics. So "black/teal" would be "black teal" and of course 3/4 stays. I dont know how to start, but do know what I cant do.I need to indicate word before the slash, word after the slash but there can be no space before the slash.


Solution

  • Use the replace method (tokens may vary depending on your regex flavor)

    Regex:

    (?i)([a-z])/([a-z])
    

    Replacement String

    \1 \2