-
Multiline TextBox Maximum Character Validation
Maximum character validation on asp.net TextBox controls do not work, therefore a RegularExpressionValidator has to be used to make sure the maximum number of characters are not exceeded e.g. <asp:TextBox ID=”tbAbstract” runat=”server” Text='<%# Bind(“Abstract”) %>’ Rows=”5″ TextMode=”MultiLine” MaxLength=”4000″/><asp:RegularExpressionValidator ID=”valAbstract” runat=”server” EnableClientScript=”false” ControlToValidate=”tbAbstract” Text=”Abstract exceeds 4000 characters” Display=”Dynamic” SetFocusOnError=”true” ToolTip=”Abstract must not exceed 4000 characters” ValidationExpression=”^[sS]{0,4000}$”…
-
Strip HTML Tags from a String using Regular Expressions
Whilst writing some code to search forum posts I had the reason to remove all HTML tags from the forum posts before I could do a valid phrase search. I created the following function: public static string StripDecodeHtml(string content){ content = HttpUtility.HtmlDecode(content); string myTagPattern = @”]*>(?<text>.*?)“; Regex myTagRegex = new Regex(myTagPattern, RegexOptions.Compiled |RegexOptions.IgnoreCase|RegexOptions.Singleline); // do until no more tags…
-
Examples of Regular Expressions
Trim string in JavaScript var trimre=’^s+|s+$’; // replace whitespacevar trimmedstring = string.replace(trimre,””); Check for a valid date format in JavaScript var re=’^(d{1,2})/(d{1,2})/(d{4})$’; // dd/mm/yyyyif (!datestring.match(re)){ alert(“Date” + datestring + ” not in valid dd/mm/yyyy format”);}else // valid date keyed in{ …valid date keyed} More to follow…
-
Creating a Banned Words Filter
I have a website with a user forum and content management system, where certain users (or anyone in the case of forums) can post to. I therefore had to create an easy way to filter and change certain naughty/controversial words from being viewed on my pages. I wanted the solution to be easy to maintain…
Recent Categories
- AJAX (1)
- APIM (5)
- Application Insights (3)
- ARM (2)
- asp.net (12)
- Azure (19)
- Azure Function (6)
- Bash (2)
- bicep (4)
- BizTalk (3)
- blob storage (1)
- Business (1)
- button (2)
- c# (7)
- CI/CD (6)
- code coverage (1)
- connection (2)
- cross browser (1)
- css (2)
- D365 (1)
- database (2)
- debug (4)
- deployment (5)
- deployment slot (1)
- devops (5)
- durable (1)
- firefox (3)
- General (28)
- html (2)
- ie (4)
- Integration Monitoring (2)
- javascript (5)
- Key Vault (2)
- liquid transformation (1)
- Logic App (4)
- Logic App (Std) (5)
- Monitoring (2)
- Nodinite (2)
- Office (1)
- ordered lists (1)
- postback (1)
- Postman (1)
- regular expressions (4)
- Service Bus (3)
- sftp (1)
- sql (3)
- terraform (1)
- Uncategorized (2)
- unordered lists (1)
- visual studio (6)
- VS Code (1)
- winforms (2)
- xml (2)
- xslt (2)
- yaml (2)
- yui (1)
- zero downtime (1)
Recent Posts
Post Archive
- September 2024
- August 2024
- July 2024
- June 2024
- May 2024
- April 2024
- December 2023
- September 2023
- April 2023
- February 2023
- January 2023
- December 2022
- November 2022
- September 2022
- August 2022
- April 2022
- February 2022
- January 2022
- December 2021
- March 2018
- February 2017
- October 2013
- September 2013
- October 2008
- May 2008
- April 2008
- March 2008
- February 2008