Created
May 8, 2014 11:10
-
-
Save zmajstor/f30a0e46017cfa3b1ca2 to your computer and use it in GitHub Desktop.
build string based on input strings and regex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# input parameters (from LDAP or device attributes SERIAL, UDID) ... | |
param1 = "abcdefgh12345678" | |
param2 = "qwertyui09876543" | |
param3 = "asdfghjkl@zxcvbnml" | |
# take first 5 non-whitespace character | |
regex1 = /^\S{5}/ | |
# take last 4 non-whitespace character | |
regex2 = /\S{4}$/ | |
# take all non-whitespace characters after @ | |
regex3 = /(?<=@)\S+/ | |
print "cn = " | |
puts "#{param1[regex1]}-#{param2[regex2]}.#{param3[regex3]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment