Alright, on certain site, I've seen the messages that say "No spaces in the username/password" Or "Illegal characters: '/,\,&,%,$,#,@ (etc.)'" and I was wondering how that's done because as you can see, it has to search for many characters. (data is posted, then these messages appear)
2 1008
Sounds like a job for regEx, have a look at the "preg" functions, start maybe with
preg_match + the regex OR operator ( "|" )
see http://php.net/preg_match
As suggested by ManWithNoName they will be using preg_match or some other regular expression based function.
However they won't be checking for all characters that cannot be used they will be checking if the string only contains characters that can be used. A username for example may only allow letters and numbers so they could use the following regular expression:-
'/[a-zA-Z0-9]+/'
If it fails then they are using an illegal character. Whenever you do such checking you should check for allowed characters rather then disallowed characters otherwise you have to go through everything that is not allowed and there is much more scope of missing something.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Sims |
last post by:
Hi,
Given a string $txt and an array of strings $txt_array
what would be the best/fastest way to search in _insensitive_ case if $txt
is in $text_array and, if it is, where is it?
Because I want to use the array with an ID
Something like,
|
by: jblazi |
last post by:
I should like to search certain characters in a string and when they are
found, I want to replace other characters in other strings that are at
the same position (for a very simply mastermind game) for my pupils.
This very simple thing does not seem simple at all.
If I use strings, I cannot replace their parts (though I can use
string.find for the searching). I think it is a bad idea that strings are
not mutable, but I suspect that...
|
by: tgiles |
last post by:
Hi, all. Another bewildered newbie struggling with Python goodness. This
time it's searching strings. The goal is to search a string for a value.
The string is a variable I assigned the name 'myvar'. however, it
doesn't seem to be seeing it... Here's a snippet.
import re
# list of items to search...
mylist =
# my variable I want to search with...
|
by: ingsms |
last post by:
Hi,
Does anyone have any suggestions on an approach to speed this up
please?
I need to check a given column in a given table to see whether there
are any characters within any of the records that fall outside of a
range of valid ASCII characters.
My problem is that of speed. The approach I have taken is to write a
|
by: Stewart Allen |
last post by:
Hi there
I'm trying to find part serial numbers between 2 numbers. The user selects a
part number from a combo box and then enters a range of serial numbers into
2 text boxes and the resulting query should find every machine that has that
part number between the serial number range.
The problem is that the serial number stored is a text field and the results
are not what they should be.
| |
by: Paul H |
last post by:
I have a text file that contains the following:
********************
__StartCustomerID_41
Name: Fred Smith
Address: 57 Pew Road
Croydon
|
by: Gordon Knote |
last post by:
Hi
can anyone tell me what's the best way to search in binary content? Best if someone could post or link me to some source code (in C/C++).
The search should be as fast as possible and it would be great if the engine (or so) would accept multiple parameters (like a search offset, a max number of bytes to search in etc.)
Any ideas
Thanks a lot again
Gordon
|
by: Cor |
last post by:
Hallo,
I have promised Jay B yesterday to do some tests.
The subject was a string evaluation that Jon had send in. Jay B was in doubt
what was better because there was a discussion in the C# newsgroup on 25
September. The regular expressions where in that newsgroup too involved.
I told yesterday night, to Jay that I would test all 4 methods and the
stupid method I was thinking of the first time that night when I saw Jon's
|
by: Kassimu |
last post by:
Hi guys out there,
There is this database Iam creating, I have a table with 40 fields among which there are Date/time, Text, Number, Memo and Yes/No fields and I have created the form bound to that tabe. I have also created Unbound form (for searching purpose) which is similar in layout with the bound one; in this search form the user will fill-in the keywords in as many text boxes as he wish to narrow down the search. The search results are...
|
by: Alexnb |
last post by:
This is similar to my last post, but a little different. Here is what I would
like to do.
Lets say I have a text file. The contents look like this, only there is A
LOT of the same thing.
() A registry mark given by underwriters (as at Lloyd's) to ships in
first-class condition. Inferior grades are indicated by A 2 and A 3.
() The first three letters of the alphabet, used for the whole alphabet.
() In church or chapel style; -- said of...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |