Showing posts with label regexp. Show all posts
Showing posts with label regexp. Show all posts

Friday

variables in dot net regular expressions

search pattern :  \s*<Merchant>\s*<ID>(?'d'.*?)</ID>
replace pattern:
NF:${d}.xml
<Merchant>
        <ID>${d}</ID>


As you can see d is variable declared in  search pattern and used into replace:
Also here is interpretation of search pattern :
Options: dot matches newline; free-spacing

Match a single character that is a “whitespace character” (spaces, tabs, line breaks, etc.) «\s*»
   Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
Match the characters “<Merchant>” literally «<Merchant>»
Match a single character that is a “whitespace character” (spaces, tabs, line breaks, etc.) «\s*»
   Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
Match the characters “<ID>” literally «<ID>»
Match the regular expression below and capture its match into backreference with name “d” «(?'d'.*?)»
   Match any single character «.*?»
      Between zero and unlimited times, as few times as possible, expanding as needed (lazy) «*?»
Match the characters “</ID>” literally «</ID>»




Tuesday

mask credit card by regular expressions (regexp) in (Regex.Replace/vb.net)



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim regFind As String = "<AccountNumber>(?'f'\d?)\d\d\d\d\d\d\d\d\d\d(?'e'.*?)</AccountNumber>"
Dim regReplace As String = "<AccountNumber>${f}**${e}</AccountNumber>"
TextBox1.Text = Regex.Replace(TextBox1.Text, regFind, regReplace)
End Sub

dot.net 3.5 from visual studio 2008

Regular Expressions - Strong Password Validation


string r =
@"(?x)" + // Ignore spaces within regex expression, for readability
@"^" + // Anchor at start of string
@"(?=.* ( \d | \p{P} | \p{S} ))" + // String must contain a digit or punctuation char or symbol
@".{6,}"; // String must be at least 6 characters in length

Console.WriteLine (Regex.IsMatch ("abc12", r));
Console.WriteLine (Regex.IsMatch ("abcdef", r));
Console.WriteLine (Regex.IsMatch ("ab88yz", r));


more...

make ubuntu business casual

to make ubuntu business casual - make it black remove background: gsettings set org.gnome.desktop.background picture-options ...