Creating a simple regular expression [closed]

I’m trying to create a regular expression that matches words with the following condition:

  • Match words which can contain characters like: æøå, and numbers.
  • If a word contains any of the following characters, it is invalid:
    + – & | ! ( ) { } [ ] ^ ” ~ * ? : /

So for example these words are okay:

testæøå
test12
12test

But these should fail:

t+st
te&st

Simple regular expression question

I’m looking for a regular expression for one of my particular requirement explained below. I believe that this may be very simple & basic for the regex experts. A regular expression that matches o

Simple regular expression substitution

I’m trying to take all instances of ‘.UpdateText(Text here);’ and turn it into ‘.Text = Text here;’ I’ve combed over regular expression sites but I can’t seem to find something so simple… Any he

Simple string regular expression

I’m trying to write very simple regular expression – this world is entirely new for me so I need an help. I need to validate the next pattern: starts with C0 and finish with 4 digits exactly for examp

Simple JavaScript Regular Expression

I’m sure this is really simple but I haven’t been able to create one that works. I need a regular expression to extract a one or two digit number 1-13 from a string such as (11) or (3) Thanks 🙂

A simple regular expression

I am not familiar with regular expression. For a string, I want to replace all the non-letter and non-digit characters with space, and then merge the spaces so that there is no two consecutive spaces

Java Simple Regular Expression Error

I have been trying to write regular expression for very simple string but have not been able to do so: x = abc 10 def price 100 ghi I tried regex: (//w//s)+(price)(//s//w)+ String regex = (//w//

Simple Regular expression question

I have a large malformed test HTML document which I need to get the numbers out of: I’d like to get the primary ratio out. I’m using this regular expression: (?<=Primary ratio</TD><TD>-

Simple Regular Expression matching

Im new to regular expressions and Im trying to use RegExp on gwt Client side. I want to do a simple * matching. (say if user enters 006* , I want to match 006…). Im having trouble writing this. What

Simple regular expression not working

I am trying to match a string with a regular expression but it is not working. What I am trying to do is simple, it is the typical situation when an user intruduces a range of pages, or single pages.

Issue on Using Regular Expression in PHP Simple Validation

I am trying to learn Regular Expression in PHP by creating simple samples.Here I have very simple example as: if($_POST){ $errors = array(); if(isset($_POST[‘name’])){ if(!preg_match(‘/^([a-zA-Z]{3,8

Answers

How about something like [^+/-|!(){}/[/]/^”~*?://]+. This will match anything that does not contain the characters you want to exclude. You’ll have to check that I’ve backslashed the meta-characters rightly within the enclosing [ and ]

Just in case you don’t know, regex in C# is much slower than string manipulation: Regex in C#
Yet, you can increase the speed if you optimize it using Regex.Compiled. This does cause your program to start up slower, however. If this is going to be any sort of web-based (C#/Silverlight), I highly recommend using String manipulation and searching over Regex, as it is going to be incredibly-slow for anyone using the page otherwise.

You can easily match Unicode or ASCII codes of characters and accept/deny words from there, with much better performance.

If you are determined to use regex, consider Perl, or other scripting languages, that are much faster with string manipulation using Regex.