Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search For Particular Characters 1

Status
Not open for further replies.

likelylad

IS-IT--Management
Joined
Jul 4, 2002
Messages
388
Location
GB
What I would like to do is to search for all characters that exist between Alt0128 to Alt0255 in the ISO8859-1 character map.

I would prefer to search by the Alt key if possible.

I know I should be using something similar to the following

preg_match_all("/[A-Za-z0-9]/",$line1,$chars1);

but I want to replace A-Za-z0-9 with Alt0128-Alt0255

Hopefully I am explaining myself properly.

Thanking in advance for any help received
 
You mean those characters you can access on Win32 by holding down ALT, entering a 4-digit numerical string, then letting up the ALT key? Those are just ASCII high-order characters.

For example, with the following HTML:
Code:
<html><body>
	<form method="post" action="/test_input.php">
		<input type="text" name="foo"><br>
		<input type="submit">
	</form>
</body></html>

Submitting to the following script, test_input.php:
Code:
<?php
print ord($_POST['foo']);
?>

If I point a browser to the HTML page, enter in the text box ALT+0233 (the "[&eacute']" character) and submit, I get the return:

233


In the preg_* family of functions, you can specify the ASCII of a character in octal, so you can use a match pattern like '/[\200-\377]/' to find these characters.

Modifying test_input.php as:
Code:
<?php
if (preg_match ([blue]'/[\200-\377]/'[/blue], $_POST['foo']) == 0)
{
	print 'not ';
}

print 'found';

?>

Lets me search for a high-order character in a string


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top