Another Regular Expression Question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • malantha
    New Member
    • Nov 2006
    • 5

    Another Regular Expression Question

    Here is what i am trying to do:
    I have a paragraph of text that I am parsing through looking for specified key words or phrases. The keywords/phrases are contained in an array that I loop through and the keyphrase could be written two ways:
    Some: Title or Some Title
    Without breaking the keyphrase (becuase it is stored in a variable) before i search the paragraph, how can I, within the same regular expression, do the following
    if the keyword is Some: Title, match anything in the paragraph that is either Some Title, or Some: Title

    i am useing preg_replace
  • vssp
    Contributor
    • Jul 2006
    • 268

    #2
    Hi friend

    Can u expline what u want


    what the problem ?

    Comment

    • malantha
      New Member
      • Nov 2006
      • 5

      #3
      Originally posted by vssp
      Hi friend

      Can u expline what u want


      what the problem ?

      OK I have a pragraph that looks like this:
      ---------
      Following the Crisis on Infinite Earths story, DC began to reboot all its properties. Uniquely though, most of the Silver Age Batman stories remained canon, with DC only wishing to revisit Batman's early years. The story was followed up by Batman: Year Two, but in the 1994 Zero Hour company wide crossover, it was erased from continuity. Catwoman: Year One (Catwoman Annual #2, 1998) tied into Catwoman's scenes, stating that the character had not been a prostitue, but rather a thief posing as one to help her commit crimes.
      --------


      I have a list of keywords that I want to highlight in the array:
      --------
      array("Batman Year Two", "Catwoman Year One");
      --------

      What I want to do is that when the phrase "Catwoman Year One" OR "Catwoman: Year One" is found in the paragraph I am searching, I want to be able to match on either/both (if both are there) the one containing the ':' and the one without. I want to be able to do this with out breaking the phrase up before hand (say on a ':' ) and compairing every word. Is there a way, with a regular expression to do something like

      find all occurences of $someVar (eg, Catwoman Year One), in the paragraph reguardless of wheither or not the version in the paragraph contains a ':'?

      Does that make it any clearer?

      Comment

      • moishy
        New Member
        • Oct 2006
        • 104

        #4
        Try the "stristr($strin g,$find);" function

        Comment

        • malantha
          New Member
          • Nov 2006
          • 5

          #5
          Originally posted by moishy
          Try the "stristr($strin g,$find);" function
          normally i would do that, but i am trying to find and replace.

          Comment

          Working...