I'm asking the question for once!
Say I have the expression @[^a-zA-Z0-9_-]@ that matches anything other than the characters specified. I also want spaces to be allows, including \n, \t, etc. I've tried adding a simple space into the expression such as @[^a-zA-Z0-9_- ]@, but that doesn't seem to work.
Anyone know how to do this? I could just match any disallowed characters, but I'd rather go this way.
Thanks,
Mark(us).
6 5421 Atli 5,058
Expert 4TB
I don't get it.
If you are specifying the characters that are *not* allowed, the expression should allow all white-spaces.
If you want them to be excluded, try adding a \s into the expression. That represents all white-space characters.
Maybe I'm just not getting the problem.
Haven't had any coffee today :P
@Atli
No, no. I'm specifying that characters that are allowed. @Atli
Ah, there you go! Thanks, Atli. @Atli
You solved the problem, even when you didn't understand!
:D
Atli 5,058
Expert 4TB
Ahh ok. I see now :)
Although, in your expression [^a-zA-Z0-9_-], I always thought the ^ char inverted the class... meaning that it represented everything but the specified chars.
That was using the Perl-compatible regex tho. Maybe your using something else?
Then again. I might still not be understanding.
(Still haven't had any coffee... trying to quit :P)
@Markus
The hyphen has special meaning inside of square brackets, which might be what threw it off. Try moving the space before the hyphen, e.g.:
Alternatively, you can simply escape the hyphen: @Atli
Well, yeah. The characters that are in the regex are those that are allowed. The ^ character checks for anything other than the specified characters.
@pbmods
I'll give it a look. Thanks, Pb.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: ajikoe |
last post by:
Hello,
For example I have a string : "Halo by by by"
Then I want to take and know the possition of every "by"
how can I do it in python?
I tried to use:
p = re.compile(r"by")
m =...
|
by: Derek Stone |
last post by:
In my continuing inability to completely understand regular expressions I
have a new one for you.
I'd like to capture a string "A" unless it is anywhere in between string "B"
and string "C".
...
|
by: aliensite |
last post by:
My code is too greedy, how can it be fixed?
Here is my code:
Desired output - First:,Second:,Third:
<br>
<script type="text/javascript">
var regEx = /*?:/g;
var html = "<br>First:ratio<br...
|
by: Johnny Lee |
last post by:
Hi,
I've met a problem in match a regular expression in python. Hope
any of you could help me. Here are the details:
I have many tags like this:
xxx<a href="http://xxx.xxx.xxx" xxx>xxx
xxx<a...
|
by: Paul Johnston |
last post by:
Hi Just started using c# to do a task I usually use Perl to do and hit
a limit in my knowledge :-)
I have a program which reads from a large text file, extracts certain
lines then gets a string...
|
by: Randy Webb |
last post by:
I know that the /g flag will match all occurrences. Is there a way, with
a Regular Expression, to match all occurrences *except* the last one?
pattern = /df/g;
var myString = "asdfasdfasdfasdf";...
|
by: teo |
last post by:
match word with interpunctuation
Hallo,
I need to build a regular expression
able to match a specified word,
preceded and followed by few chars (mainly interpunctuation)
Below the code.
...
|
by: gfrith |
last post by:
Hi,
A quick regex question which I've worked around for the time being,
but would like an answer to if anyone can help.
I want to match on all strings which end _id, but not those ending...
|
by: Sal Sal |
last post by:
If I have a string as follows
XXXasdf23s5\r\n
asdflkoirfn329i4\r\n
sef29384ewrj28039\r\n
XXX123sd3t334\r\n
sdorfu23984rr\r\n
sdflk2893rjf\r\n
weirj2983jhwer2398\r\n
XXX12356789\r\n
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |