Jump to content

dwayn

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

dwayn's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. dwayn

    Help with Regex

    there is not just 1 word of this format in $text ... there are many words of this format.... Also, could you please explain your regex expression.. I didn;t understand it!
  2. dwayn

    Help with Regex

    well, situtaion is kinda like this.... I have text(not links) which is stored in $text and in this text i have some words in this format "Step:111.Description:this is testing of &.Link:http://localhost/view.php?s=2&a=4.End" what i want to do is to replace these words with the number specified after Step: and add lines in these format at the end of the $text. Format = "[number after Step:] - <a href="link specified after Link:">(Text specified after Description:)</a> so here is the code i wrote: $rege= "~Counter:([0-9]+)\.Title:([a-z|A-Z| |&|0-9|*|,]+)\.Url:(http://localhost/view.php\?s=[0-9]+&a=[0-9]+)\.End~"; $message=preg_replace_callback($rege,create_function('$matches,$message','$message=$message."<br/>[$matches(1)]-<a href=\"$matches[3]\">$matches[2]</a>"; return "[$matches(1)]";'),$message); Errors: PHP Notice: in file /view.php(1494) : runtime-created function on line 1: Missing argument 2 for __lambda_func() Also, the regex expression is not matching the text.... I tried it matching online , it worked there but not in the code..don't know why.. Please help!
  3. dwayn

    Help with Regex

    Hey Crayon Violent, i got stuck again.. How to pass some extra arguments to the callback function.. Like e.g. $matches is the only argument that is being passed currently.. what if i want to pass another variable $story to callback function so that i can append matched text to this variable $story? Any suggestions?
  4. Hi all, What am trying to do is to find links in a string and replace them. Situation is that the link need not be separated by spaces... e.g. Contrary to popular belief, http://example.com/xyz=pqr Lorem Ipsum is not simply random texthttp://example.com/xyzzzzz=pqrs.... It has roots in a piece of classical Latin literature from 45 BC, making http://example.com/xyz=pqrrrrrrrit over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, lookedhttp://example.com/xyz=pqr should come like this(assuming replacement string is "Hello") Contrary to popular belief, Hello Lorem Ipsum is not simply random text Hello. It has roots in a piece of classical Latin literature from 45 BC, making Hello it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked Hello i.e with proper spaces in the output no matter whats in the output.... Any suggestions on how to do it?
  5. dwayn

    Help with Regex

    Yeah.. i got it ... Thanks again
  6. dwayn

    Help with Regex

    Ok..that was a stupid question... I got it all working.. Just one small query with another regex.. preg_match_all($regexExpr2, $value, $numbers, PREG_PATTERN_ORDER); echo "$numbers[0][0] $numbers[0][1]"; is printing Array[0] Array[1] instead of 2 matches that are found in string $value.... So Confused.. Any suggestion? P.S talking about the edit you did, suppose i get two matches , each match having 2 groups that i want ultimately... How will i use it? $matches[0] will be an array containing two full match string, $matches[1] will be an array having 1st group elements of 2 complete matches and so on?? P.P.S i tried it out.. Thanku so much for your reply.. really a help.. Thanks a lot.
  7. dwayn

    Help with Regex

    Hi there, thanks for the reply...i just tried things using preg_replace_callback(), i think the situation is just the same.... For every match in subject i have different elements in replacement array.. like e.g if i get two matches in subject string, than i want 1st match should be replaced with some string and other match with some other string.. If i use preg_replace_callback() , here i will be having same replacement string for all the matches.. Isn't it? Any workaround?
  8. dwayn

    Help with Regex

    Thanks for the reply... Yeah i did that..(Just before you replied ) but still NO OUTPUT ... I escaped '?' and applied delimiter too '~' .. still echo "$message" ; prints nothing...... Any reason that you can see? or some mistake? P.S. Thanks for the suggestion..I'll definately do that
  9. Hi all, I am working on a project that require finding links (of format "localhost/view.php?s={some_integer1}&a={some_integer2}" and than finding some_integer1 and some_integer2 in each link found in above string. And finally, some computation is done on basis of value of these some_integers1 and 2 and array $replacement is made ready and finally preg_replace() is caleed... The problem is i am not getting anything as output... Code: <?php $message = "hen an unknown printer took a galley of type and localhost/view.php?s=324&a=2433 scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic localhost/view.php?s=33&a=222 typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing"; $regexExpr = "localhost/view.php?s=[0-9]+&a=[0-9]+" ; preg_match_all($regexExpr, $message, $matches, PREG_PATTERN_ORDER); // some computation done on basis of values stored in $matches[0] array $regexExpr = "[0-9]+"; $i=0; foreach ($matches[0] as $key => $value ) { preg_match_all($regexExpr, $value, $forum, PREG_PATTERN_ORDER); // some computation done and $replacement array get some values here.($forum[0] array and variable $i are used in that computation). } $regexExpr = "localhost/view.php?s=[0-9]+&a=[0-9]+" ; $message = preg_replace($regexExpr, $replacement, $message); echo "$message" ; ?> Output=Nothing .. What could be the problem? Any idea... Is regex used correct? Or maybe i have used variables which are not defined earlier(but than php assume it by itself.isn't it?)
  10. Can you explain your logic please... coz i just don have if else.. i have values of flag upto 10 and tere is different code of display for each flag. what is this isset($flag) and $flag==") ....
  11. Actually what i want is that if flag equals 0 then the form should be like this else if flag equals 1 than form should contain completely different elements... If i do what u just wrote, than that html code betwen two php tags is getting executed no matter what is the value of flag... Any advice?
  12. Hey thanks a lot.. So, this kind of error appears when there is some mistake in php syntax ..eh?
  13. Hi every1, I am quite a newbie in php so please bear with ma silly questions.. I use IIS 6.0 . I have a php file named try.php . content is as folows <html> <head>......</head> <body>........som html code here... <?php if (flag==0) { some html code } ?> ...some html code </body> </html> when i open the file it says Error Summary HTTP Error 500.0 - Internal Server Error The page cannot be displayed because an internal server error has occurred. Can anybody tell me what am i doing wrong... It happen with me almost every now and then.. Is there some conceptual mistake am doing? Please clarify.. If the same question has been discussed thousand times before, than do direct me to the proper link... Regards, Dwayne
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.