473,657 Members | 2,492 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question on RegularExpressi on

Hello,

In a search form, i want to permit few characters (see below) and some signs
as - _ / , .
So thios my RegularExpressi on and it works.

ValidationExpre ssion="[a-zA-Z 0-9-_/,.]{4,20}"
But i'd would like to permit the sign ? in my string, but only one or two
occurence., like this.

Search : 123?456?
I don't manage to do it. All my tests are wrong.
thanks.
fabrice
Nov 19 '05 #1
1 1041
fabrice wrote:
Hello,

In a search form, i want to permit few characters (see below) and
some signs as - _ / , .
So thios my RegularExpressi on and it works.

ValidationExpre ssion="[a-zA-Z 0-9-_/,.]{4,20}"
But i'd would like to permit the sign ? in my string, but only one or
two occurence., like this.

Search : 123?456?
I don't manage to do it. All my tests are wrong.
thanks.
fabrice


You could try this:
([a-zA-Z 0-9-_/,.]+[?]?){0,2)[a-zA-Z 0-9-_/,.]*

but then you lose the maximum-length check.

explanation:
- one or more of your characters
- optionally followed by a ?
- the above repeated 0 to 2 times
- possibly followed by characters

Hans Kesting
Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2787
by: mg | last post by:
Does someone have RegularExpression code (C# WebForm) for server-side validation of Date (mm/dd/yyyy) ... including leap year?
2
2732
by: John Hoge | last post by:
I have a regex "^\d{5}$" that does not allow blanks, but the RegularExpressionValidator does not fire for empty fields. Is there a way to make it do so? I would rather not include a separate RequiredValidator for reasons of brevity and neatness. Thanks, John
1
1918
by: Nicola Farina | last post by:
Hi all, i've a form with a textbox that user "must" fill with a password. I want to check if there's a password inside, and if it's between 6 an 8 chars. I've placed a regularexpression validator pointing this textbox and with the following expression: \w{6,8}
2
1227
by: Fabio | last post by:
Hi all, I have this simple string for example: anything<font>catch this</font> and I need a regularexpression to Catch "catch this" so, I can use this pattern: ">+"
5
5091
by: Chris | last post by:
How Do I use the following auto-generated code from The Regulator? '------------------------------------------------------------------------------ ' <autogenerated> ' This code was generated by a tool. ' Runtime Version: 1.1.4322.2032 ' ' Changes to this file may cause incorrect behavior and will be lost if ' the code is regenerated. ' </autogenerated>
2
2205
by: den 2005 | last post by:
Hi everybody, How do restrict entering these characters <>\"%';()& and telling user these caharcters are not allowed to be enter in the textbox field using RegularExpression Validator? I put in the Validation Expression property . It restrict every character execpt 0 to 9. How to fixed this? I used + in validation Expression property of Regular Expression Validator Control. All are working except when entering the character \, which...
3
1742
by: Arpan | last post by:
Consider the following code which validates a TextBox using RegularExpression: <form id="form1" runat="server"> <asp:TextBox id="txt1" runat="server"/> <asp:RegularExpressionValidator ControlToValidate="txt1" ValidationExpression="{5}-{4}|{5}" ErrorMessage ="Invalid Input" Display="Dynamic" runat="server"/> <asp:Button id="btn" Text="SUBMIT" runat="server"/> </form>
1
1526
by: Arpan | last post by:
Using RegularExpression, I want to validate a TextBox so that the TextBox accepts only 8-digit numbers. This can be done with the following RegularExpression: {8} But how do I validate the TextBox so that it accepts 8-digit number or more than 8-digit numbers using RegularExpressions? Also how do I validate the TextBox so that it accepts 8 or more than
1
2031
by: prp | last post by:
hi all, I have a problem.Suppose I use a regularexpression validator for zip code. An User fill wrong entry in the relevant textbox then regularexpression validator fires.but user did not correct the entry and press the signup button . At that time i want setfocus on that zip textbox. all such things happen in asp.net and i want javascript for the setfocus.
0
8403
marktang
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...
0
8316
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,...
0
8833
Oralloy
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...
1
8509
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,...
0
7345
agi2029
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...
1
6174
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5636
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
1967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1730
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.