Completely new to Regex(and Xojo for that matter) but am having to use it for this application at work as I was told it would be the easiest way.
I know my search pattern works because I tested it in RegExRx. However, I cannot figure out how to get the info I need to be displayed in the textField.
Note... I am trying to just get it in the Text Field for now, and will try to figure out how to get it added into a list box under the appropriate columns. But that's for another day.
First - Everything works up to line 50. It displays the following info to the Text Box:
kMDItemColorSpace = "RGB"
kMDItemDisplayName = "getme.jpg"
kMDItemKind = "JPEG image"
kMDItemPhysicalSize = 16384
kMDItemPixelHeight = 208
kMDItemPixelWidth = 250
kMDItemProfileName = (null)
kMDItemResolutionHeightDPI = 96
After line 50, when I get into the Regex Search stuff, is where I'm getting lost.
What I want is to print the searched pattern to the text box. The pattern is simply taking the characters in-between the quotes and also any numbers, as I only care about that data. So it should output:
I added in the MsgBox for quick output. Each time, it pops up with nothing.
Here is my full code:
dim sh as new Shell dim openFile as FolderItem dim fileName as String dim modFileName as String dim fileType as String dim fileSize as String dim imageColor as String dim profile as String dim dpi as String dim dimensions as String dim height as String dim width as String dim output() as String dim imageCommands(9) as String if obj.FolderItemAvailable then openFile = obj.FolderItem //shell commands fileName = "-name kMDItemDisplayName" fileType = "-name kMDItemKind" fileSize = "-name kMDItemPhysicalSize" imageColor = "-name kMDItemColorSpace" profile = "-name kMDItemProfileName" dpi = "-name kMDItemResolutionHeightDPI" height = "-name kMDItemPixelHeight " width = "-name kMDItemPixelWidth " //Array of metadata attributes imageCommands(0) = fileName imageCommands(1) = fileType imageCommands(2) = fileSize imageCommands(3) = imageColor imageCommands(4) = profile imageCommands(5) = dpi imageCommands(6) = dimensions imageCommands(7) = height imageCommands(8) = width //Shell execution sh.Execute("mdls " + Join(imageCommands, " ") + openFile.ShellPath) dim s as string s = sh.result //THIS IS LINE 50 => //txtResults.text = s //Regex stuff Dim rg as New RegEx Dim myMatch as RegExMatch Dim result as String rg.SearchPattern="(?mi-Us)""([^""]*)""|(\d*)" //find everything inside quotes and any numbered strings myMatch = rg.Search(s) //searches the returned shell string result = myMatch.SubExpressionString(1) //No matter what number i put in here, 0-2, nothing works if myMatch is nil then MsgBox("text not found") //txtResults.text="Text not found!" else MsgBox(result) //txtResults.text = result end if end if