C# - Format Ssn Using Regex

Mar 10, 2011

I need regex in c sharp to display SSN in the format of xxx-xx-6789. i.e 123456789 should be displayed as xxx-xx-6789 in a textfield. The code I am using write now is

string SSN = "123456789";
Regex ssnRegex = new Regex("(?:[0-9]{3})(?:[0-9]{2})(?:[0-9]{4})");
string formattedSSN = ssnRegex.Replace(SSN, "XXX-XX-${last}");

What is correct Reg Expression to mask ssn xxx-xx-6789 ?

View 1 Replies


Similar Messages:

Use Regex.IsMatch To Validater Time Format (HH:mm)?

Apr 28, 2010

I would like to make sure a time with correct format (HH:mm)

this is my code

bool timeCheck = true;
string[] time = ArrivalTIME.Text.Split(':');
if (time.Length > 2)
{
if (time[0].ToString()< 0 || time[0].ToString() > 23)
timeCheck = false;
if (time[1].ToString() < 0 || time[1].ToString() > 59)
timeCheck = false;
}
else
timeCheck = false;

but this code will cause some problem ArrivalTime.Text = "aa:bb" caused syntax error..

just wondering would this check done by Regex ?

View 4 Replies

Web Forms :: Regex Formatting Raw Number To Currency Format?

Aug 16, 2010

I am trying to take user supplied raw numeric values (these numbers dont have decimal point) and correctly format the values to their correct currency display.


eg: user enters 2341 the routine would use regex to format it to 23.41

I cant find a way to do this. What I have tried is this:

[Code]....

It doesnt work.... sNjunk always comes out 299 instead of 2.99.Anyone out there that can help me with this? or point me in the right direction?

View 6 Replies

Using RegEx With LINQ - Insert A Value Into The Regex?

Feb 19, 2010

I'm having a little trouble with using regex in linq. I want to be able to perform a search on values in my database. The goal is to insert a value into the regex and then use that to search a column in a table in my database for that term. I want it to work so that it gets all exact matches and also returns matches in which the search term is a substring of the term in the column.

I was trying to follow this tutorial on msdn, but it doesn't quite fit perfectly with my problem:

[URL]

Code:

[code]....

View 11 Replies

DataSource Controls :: How To Format The Date To Uk Format With The Select Statement Through Objectdatasource

Jun 23, 2010

I have a objectdatasource control with a field of date and time and I was wanting to know how you format the date to uk format with the select statement through my objectdatasource. And what type of integer is bigint in SQL?

View 3 Replies

Web Forms :: How To Format Regular Expression Which Accepts Only Valid Email Format Only

Mar 26, 2016

 var emailReg = /^w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+$/; 

This is my regular expression . it accepts the email such as name.name_@__domain.in How can i format my regular expression which accepts only a valid email format only. I need the email validation for above example.it is not a duplicate one.

View 1 Replies

Forms Data Controls :: Store Format Or Format Output Of Text Field Into Datalist

Mar 29, 2011

I have a text field that users enter information into a database (SQL Server). They are entering as little as a few sentances to multiple paragraphs. I can successfully display the data on my webpage, but the text field is not formatted very nicely. The output is all smashed together like one big paragraph. Ironically, when I also display the text as a tool tip it outputs as multiple paragraphs like it was entered. How can I format the output in the datalist to create a more readable text field? My datalist field is as follows:

<asp:Label id="WebDescriptionLabel" runat="server" Text='<%# Eval("WebDescription") %>' ForeColor="Brown" />

View 12 Replies

Data Controls :: Grid Export Format - Why Excel Goes In Different Format

Apr 27, 2016

When data comes more than 30 Rows in Grid then the Excel goes in different format.There is parsian/Urdu Font in Grid data.

<div id="PrintDiv">
<asp:GridView ID="gvExamReport" ClientIDMode="Static" runat="server" OnDataBound="gvExamReport_DataBound"
HeaderStyle-Height="20" HeaderStyle-HorizontalAlign="Center" OnRowDataBound="gvExamReport_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="مرتبة">

[CODE]..

View 1 Replies

Calendar Extender Date Format = How To Setup Format?

Feb 1, 2010

<asp:TextBox runat="server" ID="TextBox3"/>
<asp:CalendarExtender runat="server" ID="TextBox3_CalendarExtender" TargetControlID="TextBox3"
Enabled="True" PopupPosition="BottomLeft" FirstDayOfWeek="Monday" />


output calendar Format : 2/1/2010
I need : 01.02.2010

like here : ajax calendar

how to setup this format ?..

View 1 Replies

SQL Reporting :: How To Convert A Report In Rdl Format To Rdlc Format

Jan 6, 2011

I am trying to create reports in my asp.net application. I using Microsoft Visual Web Developer 2008 Express. I am trying to display the reports using the Report Viewer (local mode - no report server).

I originally created a lot of reports using Report Builder 2 with the intent of using Report Viewer (remote mode - with a report server). The reports that I created are in rdl format and in order to display the reports using the Report Viewer in local mode, the reports need to be in rdlc mode - (the C stands for client processing).

What is the easiest way to convert these files?

View 5 Replies

C# - Format Exception - Input String Was Not In A Correct Format

Oct 18, 2010

[code]....

Isn't this how u convert string to int ?

int.Parse(e.CommandArgument.ToString());

Whats wrong ?

View 3 Replies

AJAX :: How To Format Text In C# Into Proper JSON Format

Nov 30, 2010

I'm using jquery autocomplete to call a .aspx page which returns some matching words.

The jQuery stuff relies on a JSON feed to work. Currently, in my C# I'm formatting the output as a string, which ouputs something like this:

{ query:'aa','aardvark','aardvarks']}

I was hoping that because the string is formatted in the JSON format, that would be good enough for the Javascript to process but it appears not.

how to format this text in C# into proper JSON format which JavaScript can deal with properly?

View 1 Replies

TextBox: Display Value In One Format But Return Another Format?

Jul 9, 2010

i would like to display phone number fields on a website as (123) 456-7890 but have the system see it as 1234657890 when calling myTextBox.Text i am thinking this would require overriding the text property and cleaning it up in the overridden property but wanted to run this past the community.

View 2 Replies

C# - How To Regex For Extenionless URL

Feb 19, 2010

In my asp.net application i have url [URL] to match it i have regex

"~/(.+)" which works perfectly fine. But if i navigate to www.site.com/login.aspx again regex matches with this expression "/(.+)".

In Simple words i want a regex which only match the extenionless url. IF extension is present in the url then do not match it

<RewriterRule>
<LookFor>~/(.+)/(.+)/(.+)/</LookFor>
<SendTo>~/Shop/Item.aspx?cn=&1&it=$2&ft=$3</SendTo>
</RewriterRule>

View 3 Replies

C# - How To Replace Url Value With Regex

Dec 8, 2010

I need a regex or any other solution to replace an id in the middle of a url (not in querystring).
url example - http://localhost:1876/category/6?sortBy=asc&orderBy=Popular

replace - category/6 with category/anotherID -
routing used -
routes.MapRoute(
"categories",
"category/{categoryID}/{categoryName}",
new { controller = "Search", action = "SearchResults", categoryID = "", categoryName = "" }
);

View 1 Replies

Regex.replace [h2] To <h2>?

Aug 25, 2010

I try to replace [h2] to <h2> I use this coding:

string o = "<h2>test</h2>";
o = Regex.Replace(o, "[h2]", "<h2>");
o = Regex.Replace(o, "[/h2]", "</h2>");

But the result after the first regex is:

[<h2><h2>]test[/<h2><h2>]

So that is not what i want.

After the first 1, he should make:

<h2>test[/h2]

Whats wrong?

View 3 Replies

Two Regex Expressions In One?

Jul 28, 2010

i have the code:

Regex r = new Regex("<tag>([^<]*)</tag>");

but i want to add another set of tags to search between:

Regex r = new Regex("<tag>([^<]*)</tag>|<asd as="b">([^<]*)<asd as=j>");

this does not work.

View 1 Replies

Modifying Existing Regex?

Jan 19, 2010

i m using a regex to not allow certain characters, the below code works fine for certain html tags but not for all for i dont want the user to enter html tags for eg if i enter <nitin/> it allows but i dont want this to happen for other html tags it does not allow

!@#$%^&*()+=[]\';,/{}|":<>? or
!@#$%^&*()+=[]\';,/{}|":<>/>?

View 1 Replies

Regex For Integer Range

Jul 26, 2010

how i can implemnt a regex that cover integer range? means from 0 to 2147483647

View 9 Replies

Regex To Replace Specific Div?

Feb 8, 2010

with a regex that would replace the following. The only thing that would remain the same is the div tags, the id's and classes could change and so could the content.

<div id="nav" class="whatever">Content is whatever</div>

View 4 Replies

C# - Regex Replace - But With A Few Exceptions?

Mar 11, 2010

string lNewHTML = Regex.Replace(lOldHTML, "(word1|word2|word3)", "<a href="page.aspx#$1">$1</a>", RegexOptions.IgnoreCase);

The code works, but I need to include some exceptions to the replace - e.g. I will not replace anything i an img-, li- and a-tag (including link-text and attributes like href and title) but still allow replacements in p-, td- and div-tags.

View 2 Replies

Using RegEx Replace Function In C# ASP?

Feb 18, 2010

How do I solve the problem below? I'm creating a simple content management system, where there is a HTML template with specific markup that denotes where content should be:

<html><head></head><body><!-- #Editable "Body1" --><p>etc etc</p><!-- #Editable "Extra" --></body></html>

Separate from this, there is content in a database field that looks a little like this:

<!-- #BeginEditable "Body1" -->This is Test Text<!-- #EndEditable --><!-- #BeginEditable "Extra" -->This is more test text<!-- #EndEditable -->

As you can guess I need to merge the two, that is, replacing

<!-- #Editable "Body1" -->

with: This is Test Text. I've begun the code here. But I'm having problems using the Regex Replace function that should be located at the very bottom of that For/Each.

//Html Template
string html = "<html><head></head><body><!-- #Editable "Body1" --><p>etc etc</p><!-- #Editable "Extra" --></body></html>";
//Regions that need to be put in the Html Template
string regions = "<!-- #BeginEditable "Body1" -->This is Test Text<!-- #EndEditable --><!-- #BeginEditable "Extra" -->This is more test #EndEditable -->";
//Create a Regex to only extract what's between the 'Body' tag
Regex oRegex = new Regex("<body.*?>(.*?)</body>", RegexOptions.Multiline);
//Get only the 'Body' of the html template
string body = oRegex.Match(html).Groups[1].Value.ToString();
// Regex to find sections inside the 'Body' that need replacing with what's in the string 'regions'
Regex oRegex1 = new Regex("<!-- #Editable "(.*?)"[^>]*>",RegexOptions.Multiline);
MatchCollection matches = oRegex1.Matches(body);
// Locate section titles i.e. Body1, Extra
foreach (Match match in matches)
{
string title = oRegex1.Match(match.ToString()).Groups[1].ToString();
Regex oRegex2 = new Regex("<!-- #BeginEditable "" + title + ""[^>]*>(.*?)<!-- #EndEditable [^>]*>", RegexOptions.Multiline);
//
//
// Replace the 'Body' sections with whats in the 'regions' string cross referencing the titles i.e. Body1, Extra
//
//
//
}

View 5 Replies

C# - Regex To Get Page Number From The Url?

Jul 4, 2010

I am currently using this regex to get the page number from the url:

@"/(d+)$";

Which worked fine for urls like:

/some_category/2
/some_category2/323

My urls now have some additional querystring values (optionally), so the current regex is not working for these cases.

So now I need a regex to support:

/some_category/2
/some_category2/323
/some_category2/323?a=1&b=2
/some_category2/323?&c=123&a=1&b=2

I am using a route with wildcards so I can use the built in asp.net mvc for this.

View 3 Replies

Regex - How To Validate ID Number

Sep 7, 2010

I am new at this so be easy on me... :)

I need to validate if a the ID number that the user typed in my site is a valid ID.

How do I check it?

Do I need to use RegularExpressionValidator?

More over, I also need to validate the credit card number, I found a few RegularExpressions for that in the net but each one is different from the other and I am not sure which one to use.. Does anyone know od a working expression that will suit all credit cards?

View 2 Replies

RegEx For Strong Password?

Mar 6, 2010

I have the following password requirements:

1) Should be 6-15 characters in length
2) Should have atleast one lowercase character
3) Should have atleast one uppercase character
4) Should have atleast one number
5) Should have atleast one special character
6) Should not have spaces

Can anyone suggest me a RegEx for this requirement?

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved