Thursday, May 15, 2008

What is the % Code in My URL?

In order to prevent the misinterpretation of special characters such as a space, bracket (<>), or % in the URL (which stands for Uniform Resource Locator - it is the address you see in your browser's address bar indicating the location of the website you are visiting), browsers parse certain special characters using escape characters. This explains why when you click on a link such as: domain.com/page one.htm you see it parsed in the address bar as domain.com/page%20one.htm. In this case the %20 is the escape character for the space.
Common URL Escape Characters
Table of URL Escape Characters
Character Escape Character Character Escape Character
Space %20 # %23
$ %24 % %25
& %26 @ %40
' %60 / %2F
: %3A ; %3B
< %3C = %3D
> %3E ? %3F
[ %5B \ %5C
] %5D ^ %5E
{ %7B %7C
} %7D ~ %7E

SQL string split function

This can't be the best SQL string split function around, and it's the 3rd string split function I've borrowed to solve a problem. To stop spaghetti creep, I've got to choose one and go with it.I could pick one of the 3 string split functions I'm using, but maybe if I poll the community at large with a large pole I'll find some string split function out there that's better than sliced bread.
CREATE FUNCTION dbo.Split
( @RowData nvarchar(2000), @SplitOn nvarchar(5))
RETURNS @RtnValue table
( Id int identity(1,1), Data nvarchar(100))
AS
BEGIN
Declare @Cnt int
Set @Cnt = 1
While (Charindex(@SplitOn,@RowData)>0)

Begin
Insert Into @RtnValue (data)
Select Data = ltrim(rtrim(Substring(@RowData,1,Charindex(@SplitOn,@RowData)-1)))
Set @RowData = Substring(@RowData,Charindex(@SplitOn,@RowData)+1,len(@RowData))

Set @Cnt = @Cnt + 1
End
Insert Into @RtnValue (data)
Select Data = ltrim(rtrim(@RowData))
Return

END

Regular Expressions and C#, .NET

This Article explores the concept of Regular Expressions in the context of C#, .NET support for Regular
Expressions, Meta-characters and their Description, Character Escapes, Substitutions, Character Classes, Regular Expression Options and Atomic Zero-Width Assertions.

What are regular expressions?
Regular expressions are Patterns that can be used to match strings. You can call it a formula for matching strings that follow some pattern. Regular expression(s) can be considered as a Language, which is designed to manipulate text. You can then ask questions such as
“Does the given string match the pattern?”, or “Does the given string contain characters that match a pattern?”. Regular Expressions may be used to find one or more occurrences of a pattern of characters within a string. You may choose to replace it with some other characters or perform some other tasks based on the results obtained. These patterns of characters can be simple or very complex. Regular Expressions generally comprises of two types of characters –
1) Literal or Normal Characters such as “abcd123” 2) Special Characters that have a special meaning such as “.” Or “$” or “^”
Due to the special characters Regular Expressions form a very powerful means of manipulating strings and text.

.NET support for Regular Expressions:
.Net provides an extensive set of Regular expressions which you could use to create, modify or compare strings. They can be classified as follows –
a) Character Escapes b) Substitutions c) Character Classes d) Regular Expression Options e) Atomic Zero-Width Assertions f) Quantifiers g) Grouping Constructs h) Backreference Constructs i) Alternation Constructs j) Miscellaneous Constructs

Split the String values with a special character in MS Flow to convert this into Array

 Many times we have a requirement to prepare the Mailing address for some of the documents, suppose there are Address Line1, Address Line2, ...