Asked  2 Years ago    Answers:  5   Viewed   69 times

I'm not familiar with the how regular expressions treat hexadecimal, anyone knows?

 Answers

2

The following does the trick:

$str = "some ??????????";

echo preg_replace('/[x{00ff}-x{ffff}]/u', '*', $str);
// some **********

echo preg_replace('/[^x{00ff}-x{ffff}]/u', '*', $str);
// *****??????????

The important thing is the u-modifier (see here):

This modifier turns on additional functionality of PCRE that is incompatible with Perl. Pattern strings are treated as UTF-8. This modifier is available from PHP 4.1.0 or greater on Unix and from PHP 4.2.3 on win32. UTF-8 validity of the pattern is checked since PHP 4.3.5.

And here a short description why uFFFF is not working in PHP:

Perl and PCRE do not support the uFFFF syntax. They use x{FFFF} instead. You can omit leading zeros in the hexadecimal number between the curly braces. Since x by itself is not a valid regex token, x{1234} can never be confused to match x 1234 times. It always matches the Unicode code point U+1234. x{1234}{5678} will try to match code point U+1234 exactly 5678 times.

Tuesday, September 6, 2022
 
2

This will work only for non-nested parentheses:

    $regex = <<<HERE
    /  "  ( (?:[^"\\]++|\\.)*+ ) "
     | '  ( (?:[^'\\]++|\\.)*+ ) '
     | ( ( [^)]*                  ) )
     | [s,]+
    /x
    HERE;

    $tags = preg_split($regex, $str, -1,
                         PREG_SPLIT_NO_EMPTY
                       | PREG_SPLIT_DELIM_CAPTURE);

The ++ and *+ will consume as much as they can and give nothing back for backtracking. This technique is described in perlre(1) as the most efficient way to do this kind of matching.

Saturday, October 29, 2022
5

The standard disclaimer applies: Parsing HTML with regular expressions is not ideal. Success depends on the well-formedness of the input on a character-by-character level. If you cannot guarantee this, the regex will fail to do the Right Thing at some point.

Having said that:

<ab[^>]*>(.*?)</a>   // match group one will contain the link text
Tuesday, September 6, 2022
3

robots.txt: http://www.robotstxt.org/robotstxt.html

Not all bots respect it, but most do. If you really want to prevent access via bots, make the link to it a POST instead of a GET. Bots will not follow POST urls. (I.E., use a small form that posts back to the site that takes you to the URL in question.)

Thursday, December 1, 2022
 
ben.t
 
1

In a Visual Studio Setup project, you control the default install path by setting the DefaultLocation property of the Application Folder folder, within the File System Editor.

This, in turn, as you've found, defaults to [ProgramFilesFolder][Manufacturer][ProductName]. You can either replace this property entirely (you should keep [ProgramFilesFolder], at the very least though), or you can modify these properties.

[ProgramFilesFolder] is built in, and correctly leads to the Program Files directory on the target machine, no matter how customized the setup of Window is. The other two properties are properties of the setup project (select the Setup project in Solution Explorer, and examine the properties grid to find them). These default to the company name you supplied when installing Visual Studio, and the name of the Setup project.

Saturday, September 17, 2022
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :
 

Browse Other Code Languages