• Thanks Jeff

    your PATINDEX idea seems a step closer to a dream 'WildReplace' function which might be :

    CREATE FUNCTION dbo.fn_WildReplace(@SomeText varchar(max),

    @Pattern varchar(500), @ReplaceWith varchar(max))

    .....

    Edit: corrected syntax

    Usage :

    SELECT dbo.fn_WildReplace('Without a doubt SQLCentral is

    home to finest SQL folk[comment:#grovel].', '%[comment:#%]', '')

    --returning:

    --Without a doubt SQLCentral is home to finest SQL folk.

    The function doesn't specify any start or end markers, just a pattern to find and replace.

    I can see we can use PATINDEX to find start location of the pattern, but I canny figure out how you would determine the end location of the pattern?