I have learned Crystal by trial and error, so please forgive my phrasing.
I want to combine text and fields. If there is more than one instance of Tensile.SOItemNum, then I want to repeat all instances of that field within my resultant text string and have the multiple instances be separated by commas. (Actually I would want this section to repeat for each record of Tensile.SOITEM.
The following is the formula for one text string and this would work if there were just one record.
Formula = "0003015339|01|" & totext({Tensile.SONum},0,"") & "-" &
totext({Tensile.SOItemNum},0,"") & "-" & {Tensile.Lot} & "|" & {SOItem.CustPO} &
"|" & totext({SOItem.SOItemNum},0,"") & "|" & {SOItem.ProdCode} & "|" &
totext({ManifestLotView.Manifest},0,"") & "-" &
totext({ManifestLotView.SONum},0,"") & "-" &
totext({ManifestLotView.SOItemNum},0,"")
Which produces:
0003015339|01|114667-10-1-B-1|5400361554-R01|10|XALRET05012|27202-114667-10
If there were a 114667-10-1-B-1 and a 114668-5-2-B-1, I would want the string resultant string to read:
0003015339|01|114667-10-1-B-1,114668-5-2-B-1|5400361554-
R01|10|XALRET05012|27202-114667-10
This is some of what I was trying, but it is not a valid formula. I have not used the Next function before.
Formula = "0003015339|01|" & totext({Tensile.SONum},0,"") & "-" &
totext({Tensile.SOItemNum},0,"") & "-" & {Tensile.Lot} & IF nextvalue
({Tensile.SONum}) > 1 then "," & totext({Tensile.SONum},0,"") & "-" &
totext({Tensile.SOItemNum},0,"") & "-" & {Tensile.Lot} end if "|" &
{SOItem.CustPO} & "|" & totext({SOItem.SOItemNum},0,"") & "|" &
{SOItem.ProdCode} & "|" & totext({ManifestLotView.Manifest},0,"") & "-" &
totext({ManifestLotView.SONum},0,"") & "-" &
totext({ManifestLotView.SOItemNum},0,"")
Thank you in advance for your time.
Related
I am stumped on trying to figure out regular expressions so I thought I would ask the big dogs.
I have a string that can range from 1-4 sets as follows:
1234-abcd, baa74739, maps21342, 6789
Now I have figured out the regular expressions for the 1234-abcd, baa74739, and maps21342. However, I am having trouble figuring out a code to pull the numbers that stand alone. Does anyone have an opinion on a way around this?
Example of the regex I used:
dbout.Range("D7").Formula = "=RegexExtract(DH7," & Chr(34) & "([M][A][P][S]\d+)" & Chr(34) & ")"
dbout.Range("D7").AutoFill Destination:=dbout.Range("D7:D2000")
for digit stand alone replace
dbout.Range("D7").Formula = "=RegexExtract(DH7," & Chr(34) & "([M][A][P][S]\d+)" & Chr(34) & ")"
dbout.Range("D7").AutoFill Destination:=dbout.Range("D7:D2000")
with
dbout.Range("D7").Formula = "=RegexExtract(DH7," & Chr(34) & "(\b\d+\b)" & Chr(34) & ")"
dbout.Range("D7").AutoFill Destination:=dbout.Range("D7:D2000")
OR
dbout.Range("D7").Formula = "=RegexExtract(DH7,""(\b\d+\b)"")"
dbout.Range("D7").AutoFill Destination:=dbout.Range("D7:D2000")
I have the string of the following format:
example 1: ABC,0,ABCD,ABC,ABC,ABC,ABC,ABC,11,ABC,ABC,toRemove,012,234
example 2: ABC,0,ABCD,ABC,ABC,ABC,ABC,ABC,11,ABC,ABC, toRemove,012,234
If the string contains 14 Values (instead of 13 values) separated by comma, then remove the 12. value
The second line above contains a white space, that should also removed if exists.
StringSplit has already a counter (element 0), so no need to use Ubound).
Like StringSplit converts a string to an array, ArrayToString converts an array back to a string.
#include <array.au3>
$tmp_line = "ABC,0,ABCD,ABC,ABC,ABC,ABC,ABC,11,ABC,ABC, ToRemove,012,234"
$line = StringSplit($tmp_line, ",")
If $line[0] = 14 Then
$new_line = ArrayToString($line, ",", 1, 11) & "," & ArrayToString($line, ",", 13)
Else
$new_line = $line ; shouldn't this be $new_line = $tmp_line ?
EndIf
MsgBox(0, $line[0], $tmp_line & #CRLF & $new_line)
Solved:
$line = StringSplit($tmp_line, ",")
$count_values = Ubound($line)
If $count_values = 14 Then
$new_line = $line[1] & "," & $line[2] & "," & $line[3] & "," & $line[4] & "," & $line[5] & "," & $line[6] & "," & $line[7] & "," & $line[8] & "," & $line[9] & "," & $line[10] & "," & $line[12] & "," & $line[13]
Else
$new_line = $line
EndIf
I need to get installed software in as shows in Uninstall Program in control panel. So i used Win32_RegistryAction class for querying in vb script. But still i could not query a particular key and it hangs. Here is the piece of code which i used. Please help me how to get installed software details using wmi query.
Thanks in advance
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colSettings = objWMIService.ExecQuery _
("Select * from Win32_RegistryAction where key ='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\' and Root=2 ")
For Each objComputer in colSettings
Wscript.Echo "Display Name: " & objComputer.DisplayName
Next
You are using the wrong WMI class, you must use the StdRegProv class instead, for examples about how use this try the MSDN documentation (WMI Tasks: Registry).
Here i am answering to my own question. Thank You RRUZ for lead me in a right way. Here i have solution for this problem. Now i am able to get all installed software which are showing the uninstall program in windows. Sample code is giving here
Dim count
Const HKEY_LOCAL_MACHINE = &H80000002
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Uninstall"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames
count = 0
For i=0 To UBound(arrValueNames)
StrText = arrValueNames(i)
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "DisplayName",strName
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "DisplayVersion",strVersion
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "InstallLocation",strLocation
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "InstallDate",strDate
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "SystemComponent",strSystemComponent
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "WindowsInstaller",strWindowsInstaller
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "UninstallString",strUninstallString
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "ReleaseType",strReleaseType
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "ParentKeyName",strParentKeyName
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "Publisher",strPublisher
if isNull(strSystemComponent) then
if isNull(strWindowsInstaller) then
if not isNull(strUninstallString) then
if isNull(strReleaseType) then
if isNull(strParentKeyName) then
if not isNull(strName) then
printKeyValue "Win32_Product.PackageName[" & count & "]", StrName
printKeyValue "Win32_Product.Version[" & count & "]", StrVersion
printKeyValue "Win32_Product.InstallLocation[" & count & "]", strLocation
printKeyValue "Win32_Product.InstallDate[" & count & "]", strDate
printKeyValue "Win32_Product.Publisher[" & count & "]", strPublisher
printKeyValue "Win32_Product.WindowsInstaller[" & count & "]", strWindowsInstaller
printKeyValue "Win32_Product.UninstallString[" & count & "]", strUninstallString
printKeyValue "Win32_Product.ReleaseType[" & count & "]", strReleaseType
printKeyValue "Win32_Product.ParentKeyName[" & count & "]", strParentKeyName
count = count + 1
end if
end if
end if
end if
end if
end if
Next
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
strKeyPath = "Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames
For i=0 To UBound(arrValueNames)
StrText = arrValueNames(i)
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "DisplayName",strName
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "DisplayVersion",strVersion
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "InstallLocation",strLocation
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "InstallDate",strDate
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "SystemComponent",strSystemComponent
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "WindowsInstaller",strWindowsInstaller
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "UninstallString",strUninstallString
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "ReleaseType",strReleaseType
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "ParentKeyName",strParentKeyName
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "Publisher",strPublisher
if isNull(strSystemComponent) then
if isNull(strWindowsInstaller) then
if not isNull(strUninstallString) then
if isNull(strReleaseType) then
if isNull(strParentKeyName) then
if not isNull(strName) then
printKeyValue "Win32_Product.PackageName[" & count & "]", StrName
printKeyValue "Win32_Product.Version[" & count & "]", StrVersion
printKeyValue "Win32_Product.InstallLocation[" & count & "]", strLocation
printKeyValue "Win32_Product.InstallDate[" & count & "]", strDate
printKeyValue "Win32_Product.Publisher[" & count & "]", strPublisher
printKeyValue "Win32_Product.WindowsInstaller[" & count & "]", strWindowsInstaller
printKeyValue "Win32_Product.UninstallString[" & count & "]", strUninstallString
printKeyValue "Win32_Product.ReleaseType[" & count & "]", strReleaseType
printKeyValue "Win32_Product.ParentKeyName[" & count & "]", strParentKeyName
count = count + 1
end if
end if
end if
end if
end if
end if
Next
Function printKeyValue(key, value)
Wscript.Echo key & "=>" & value
End Function
Here the path Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall is only applicable for Windows 7 or above.
This is probably a simple question for someone experienced with regex, but I'm having a little trouble. I'm looking to match lines of data like this shown below:
SomeAlpha Text CrLf CrLf 15 CrLf CrLf 123 132 143 CrLf CrLf 12313 CrLf CrLf 12/123
Where the "SomeAlpha Text" is just some text with space and potentially punctuation. The first number is something between 1 and 30,000. The second set of numbers (123 132 143) are between 1 and 500,000 (each number). The next number is somewhere between 1 and 500,000. The final set is (1–30,000)/(1–30,000). This is the code I've put together so far:
Dim Pattern As String = "[.*]{1,100}" & vbCrLf & "" & vbCrLf & "[0-9]{1,4}" & vbCrLf & "" & vbCrLf & "[0-9]{1,6] [0-9]{1,6] [0-9]{1,6]" & vbCrLf & "" & vbCrLf & "[0-9]{1,6}" & vbCrLf & "" & vbCrLf & "[0-9]{1,5}/[0-9]{1,5}"
For Each match As Match In Regex.Matches(WebBrowser1.DocumentText.ToString, Pattern, RegexOptions.IgnoreCase)
RichTextBox1.AppendText(match.ToString & Chr(13) & Chr(13))
Next
And I'm currently getting 0 matches, even though I know there should be at least 1 match. Any advice on where my pattern is wrong would be great! Thanks.
"[.*]{1,100}" & vbCrLf & "" & vbCrLf & "[0-9]{1,4}" & vbCrLf & "" & vbCrLf & "[0-9]{1,6] [0-9]{1,6] [0-9]{1,6]" & vbCrLf & "" & vbCrLf & "[0-9]{1,6}" & vbCrLf & "" & vbCrLf & "[0-9]{1,5}/[0-9]{1,5}"
has quite a few problems:
The * in "[.*]{1,100}" tells the previous character to repeat as many times as possible, and is therefore unnecessary. Replace it with ".{1,100}" or ".*"
You say the first number is between 0 and 30000. "[0-9]{1,4}" only allows for 4 digits (0 to 9999). Replace it with "[0-9]{1,5}", which allows for any number between 0 and 99999.
You accidentally put ] instead of } at three places in this part: "[0-9]{1,6] [0-9]{1,6] [0-9]{1,6]". Replace it with "[0-9]{1,6} [0-9]{1,6} [0-9]{1,6}"
Try doing what I said above. It should work correctly.
I'm having some trouble trying to develop a regular expression which will pick out all the function calls to "tr" from this block of asp code below. Specifically I need to get the string in each "tr" function call.
if(RS.Fields("Audid").Value <> 0 ) Then
Response.Write ("<td>" & tr("RA Assigned") & "</td>")
else
Response.Write ("<td>" & tr("Not Yet Assigned") & "</td>")
End if
if(RS.Fields("rStatus").Value = "Activated") then
Response.Write("<td><A HRef='portal_setup_billingII.asp?OrderPId=" & RS.Fields("CustomerParid").Value & "&OrderId=" & RS.Fields("OrderId").Value & "'>" & tr("Edit") &"</A></td></TR>")
Else
If (gParLevelz_Admin = gParLevelz and RS.Fields("CustomerParid").Value <> 0) Then
Response.Write("<td><A HRef='portal_setup_billingII.asp?OrderPId=" & RS.Fields("CustomerParid").Value & "&OrderId=" & RS.Fields("OrderId").Value & "'>" & tr("Awaiting Authorization") & "</A></td></TR>")
else
Response.Write("<td>" & tr("Awaiting Authorization") & "</td></TR>")
End if
End if
I believe I have a good first attempt at getting this done. The following expression extracts values for most of the cases I will run into...
tr\(\"([^%]|%[0-9]+)+\"\)
What's causing me the most confusion and stress is how to capture all manner of strings which show up in the "tr" function. Literally anything could be between the quotation marks of the "tr" call and unfortunately my expression returns values past that last quotation. So given the above snippet which I have posted one of the matches is...
tr("RA Assigned %2") & "</td>")
else
Response.Write ("<td>" & tr("Not Yet Assigned %4") & "</td>")
End if
if(RS.Fields("rStatus").Value = "Activated") then
Response.Write("<td><A HRef='portal_setup_billingII.asp?OrderPId=" & RS.Fields("CustomerParid").Value & "&OrderId=" & RS.Fields("OrderId").Value & "'>" & tr("Edit") &"</A></td></TR>")
Else
If (gParLevelz_Admin = gParLevelz and RS.Fields("CustomerParid").Value <> 0) Then
Response.Write("<td><A HRef='portal_setup_billingII.asp?OrderPId=" & RS.Fields("CustomerParid").Value & "&OrderId=" & RS.Fields("OrderId").Value & "'>" & tr("Awaiting Authorization") & "</A></td></TR>")
else
Response.Write("<td>" & tr("Awaiting Authorization") & "</td></TR>")
Which is way more than I want. I just want tr("RA Assigned %2") to be returned.
It looks like your regex pattern is greedy. Try making it non-greedy by adding an ? after the 2nd +: tr\(\"([^%]|%[0-9]+)+?\"\)
A simplified version to capture anything inside the tr(...) would be: tr\(\"(.+?)\"\)
Use a question mark after the plus sign modifier to make it non-greedy (only match as much as it needs).
Also, maybe anchor against ") & " if that always follows a call to tr().
You'll need a non-greedy pattern; just add a ?, like:
tr\(\"([^%]|%[0-9]+)+?\"\)
// ^--- notice this
tr\((\"[^\"]*)\"\)
tr(\".*\")
in regex, . = anything, * = any number (including 0)
Just don't match on the equals sign for the string.
tr\(\"([^\"]+)\"\)
I'm not sure if it's perfect, but it properly retrieved all of the entries in your sample. While testing the other expressions on this page I found that some erroneous entries were being returned. This one does not return any bad data:
tr\("([\W\w\s]+?)"\)
The result returned will contain both the entire function call, and also the strings within the function. I tested it with the following input:
Response.Write ("<td>" & tr("RA Assigned") & "</td>")
Response.Write ("<td>" & tr("Not Yet Assigned") & "</td>")
Response.Write("<td><A HRef='portal_setup_billingII.asp?OrderPId=" & RS.Fields("CustomerParid").Value & "&OrderId=" & RS.Fields("OrderId").Value & "'>" & tr("Edit") &"</A></td></TR>")
Response.Write("<td><A HRef='portal_setup_billingII.asp?OrderPId=" & RS.Fields("CustomerParid").Value & "&OrderId=" & RS.Fields("OrderId").Value & "'>" & tr("Awaiting Authorization") & "</A></td></TR>")
Response.Write("<td>" & tr("Awaiting Authorization") & "</td></TR>")
Response.Write ("<td>" & tr("RA Ass14151igned") & "</td>")
Response.Write ("<td>" & tr("RA %Ass_!igned") & "</td>")
And received the following output:
$matches Array:
(
[0] => Array
(
[0] => tr("RA Assigned")
[1] => tr("Not Yet Assigned")
[2] => tr("Edit")
[3] => tr("Awaiting Authorization")
[4] => tr("Awaiting Authorization")
[5] => tr("RA Ass14151igned")
[6] => tr("RA %Ass_!igned")
)
[1] => Array
(
[0] => RA Assigned
[1] => Not Yet Assigned
[2] => Edit
[3] => Awaiting Authorization
[4] => Awaiting Authorization
[5] => RA Ass14151igned
[6] => RA %Ass_!igned
)
)
On a related note, check out My Regex Tester. It's a super useful tool for testing regular expressions in your browser.
This should do it, use non-greedy (?) after * or +:
const string pattern = "tr\\(\".*?\"\\)";
const string text = "tr(\"RA Assigned %2\") & \"</td>\")";
Regex r = new Regex(pattern, RegexOptions.Compiled);
Match m = r.Match(text);
while (m.Success)
{
foreach (Capture c in m.Captures)
{
Console.WriteLine(c.Value);
}
m = m.NextMatch();
}
(Here there is a good regex in C# cheat sheet)