Jump to content

abareplace

Members
  • Posts

    23
  • Joined

  • Last visited

Contact Methods

  • Website URL
    http://www.abareplace.com

Profile Information

  • Gender
    Not Telling

abareplace's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Use two replacements to put </ins> before </br> <?php $a = 'Hello<br <del>/>This is</del> <ins>How are you?<br </ins>/>'; $a = preg_replace( '|<br (<[a-z]+>)/>|', '<br>\\1', $a ); $a = preg_replace( '|<br (</[a-z]+>)/>|', '\\1<br>', $a ); echo $a; ?>
  2. Use preg_match instead of eregi, as the manual suggests. Remember to add delimiters to the pattern.
  3. Hi, Mark, you should check that the word ends here: ([a-z]+)\b(?!( hi)) \b is a word boundary (in this case, the end of the word).
  4. 1) Is ping output separated with commas? 2) If you need to compare the second element of the array with "0", just write if ($data[1] == '0'). No regular expression is needed.
  5. May be, it's a logical vs. visual order problem. Please try to reverse the order: /\p{Arabic)\s*:\s*(\d+)/
  6. AyKay, he wants to find URLs, not email addresses. Monkuar, please try this code: <?php $text = 'abc example.com2 abc'; if (preg_match('/(?<=[a-z0-9])\.(com|org|net|mil|edu|de|us|uk|au|info)/i', $text)) { echo "You cannot post links or urls unless you have made 10 Posts"; } ?>
  7. This is probably what you want: <?php $string = '<b>Age:</b> 16'; if (preg_match('~<b>Age:</b> (\\d+)~', $string, $match)) { echo ((int)$match[1] < 18) ? 'minor' : 'adult'; } ?>
  8. Use preg_match instead of ereg. POSIX regular expressions (the ereg function) are depreciated; you should use PCRE.
  9. If the spaces around commas are optional, then Joe's pattern should be modified in this way: /^[a-z]+\s*,\s*[a-z]+\s*,\s*[a-z]+$/i
  10. Hello, Brian, in most tools, it will not match %%some text%%, because %% is already included in the first match. For example, in PHP: <?php echo preg_replace('/%%(.+?)%%/', '[$1]', '%%match1%% some text %% match2 %% some more text %%match3%%') ?> Output: [match1] some text [ match2 ] some more text [match3] So, you don't have to worry
  11. The Little Guy, you should use a lexer here. There are too many edge cases where regexes will not work. highlight.js is a nice ready-to-use highlighter that does lexical analysis.
  12. Silkfire, the last star (*) is unnecessary: ^(\d+)\D*(\d+) instead of ^(\d+)[^\d]*(\d+)*
  13. Try ... && !phone_number.match(/^(?:1-?)?(\d)\1\1-?\1\1\1-?\1\1\1\1$/)
  14. In TextPad, .* and [^[]* cannot span multiple lines. I've tried \(.\|\n\)* It does not help, too Generally, there are some problems with multi-line searches in TextPad.
  15. McK, I'm sorry. As a geek, I'm paranoidally suspicious Your regex will work if you include the page address into lookbehind: (?<=(user/SendEmail\.jtp\?type=user&user=\d+)">Send Email to ).+(?=<) However, most regex engines don't support variable-length lookbehind (\d+ can have any length, from one character to infinity), so it will work only in .NET, RegexBuddy, or my tool. In PHP, you can use the usual capturing groups: <?php $url = '<a href="/user/SendEmail.jtp?type=user&user=195799">Send Email to shreyes</a>'; $pattern = "/(user\/SendEmail\.jtp\?type=user&user=\d+)\">Send Email to (.+)(?=<)/"; preg_match_all($pattern, $url, $userInfo); echo 'UserAddress: '.$userInfo[1][0] . "<br>\n"; echo 'UserName: '.$userInfo[2][0]; Good luck with your project! It should be very useful for the Protege community.
×
×
  • 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.