[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Regex to look for vbCrLF (carriage) or tabs

Posted on 2006-05-23
11
Medium Priority
?
897 Views
Last Modified: 2012-08-13
Hi,

Currently i have:

Regex.Match(str, "^[\w\s]+$").Success

But if the user hits enter on the multiline textbox
it causes failure to regex

How should i change
0
Comment
Question by:jedistar
  • 4
  • 3
  • 3
  • +1
11 Comments
 
LVL 27

Expert Comment

by:Sammy Ageil
ID: 16748345
Jedistar,
I am not good in regex myself but there is a tool I use for all my asp.net apps
its called regex builder and you can download it and use it for free from
http://www.gotdotnet.com/Workspaces/Workspace.aspx?id=9e33c395-8275-4906-8a09-0bff41fdc1d6

Good luck
0
 
LVL 16

Expert Comment

by:Edwin_C
ID: 16748797
try

"^[\w\s\n\t]+$"
0
 

Author Comment

by:jedistar
ID: 16751575
i need to disallow \n\t
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:jedistar
ID: 16751807
i think u made it such that it allows \n\t
0
 
LVL 13

Expert Comment

by:nurbek
ID: 16751839
you may use replace function

str = Replace(str,vbCrlf," ")

what do you mean by dissallowing \n\t? (remove them?)

do not the syntax in asp.net
it is in asp
it finds \n\r\t and replaces with white space

     Set objRegExpr = New regexp
     objRegExpr.Pattern = "[\n\t\r]"
     objRegExpr.Global = true
     objRegExpr.IgnoreCase = true
     newStr = objRegExpr.Replace(str," ")
     Set objRegExpr = Nothing
     Response.Write(newStr)
0
 
LVL 13

Expert Comment

by:nurbek
ID: 16751850
do not know the syntax in asp.net :(
0
 
LVL 16

Expert Comment

by:Edwin_C
ID: 16751943
You can use a RegularExpressionValidator like this.

<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Tab or CR is not allowed" ControlToValidate="TextBox1" ValidationExpression="[^\t\n]*"></asp:RegularExpressionValidator>
0
 

Author Comment

by:jedistar
ID: 16782687
no no im displaying from db
0
 
LVL 16

Expert Comment

by:Edwin_C
ID: 16782726
Sorry! I'm lost.  Can you tell me more about what you want to achieve and show more of your code?
0
 

Author Comment

by:jedistar
ID: 16782749
<%# DataBinder.Eval(Container.DataItem, "message") %>                 -> C# code in .aspx

the above message has new line codes inside but when i display it
it comes up as 1 line, how do i get it to display the proper new lines
0
 
LVL 13

Accepted Solution

by:
nurbek earned 1000 total points
ID: 16782875
try this

<script runat="server">
      protected string FormatOutput(object mStr)
      {
            string data = mStr.ToString();
            data = data.Replace("\n", "<br>");
            data = data.Replace("\r", "<br>");
            return data;
      }
</script>

<%# FormatOutput(DataBinder.Eval(Container.DataItem, "message")) %>  
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question