#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    10
    Rep Power
    0

    Matching partial string


    Hi

    I'm looking to match a string thats inside a <div> tag no matter how many panctuation marks and spaces are before the string or after.

    panctuations marks include: !?,()[].: and space

    example:

    the string "test word" should be replaced with <a href='#'>test word</a>

    original string: <div id='mydiv'>(test word)</div>
    expected result: <div id='mydiv'>(<a href='#'>test word</a>)</div>

    original string: <div id='mydiv'>(!?! ?test word?:?...)</div>
    expected result: <div id='mydiv'>(!?! ?<a href='#'>test word</a>?:?...)</div>

    i'm working under asp.net c#

    thank you
  2. #2
  3. Jealous Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,303
    Rep Power
    9400
    Is being inside the <div> a requirement or are you just stating what the data looks like? Or in other words what should happen with
    Code:
    <div id='mydiv'>(test word)</div> and test word
    So far it doesn't sound like you need regular expressions - it's just a simple string find/replace.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    10
    Rep Power
    0
    Originally Posted by requinix
    Is being inside the <div> a requirement or are you just stating what the data looks like? Or in other words what should happen with
    Code:
    <div id='mydiv'>(test word)</div> and test word
    So far it doesn't sound like you need regular expressions - it's just a simple string find/replace.
    you are absolutely right. lost the big picture.

    after spending 3 months on a 200-lines piece of code i just turned them into a 3 line code with simple replaces.

IMN logo majestic logo threadwatch logo seochat tools logo