Jump to content

Search a partial string in textarea field and get the complete string


Recommended Posts

Consolewrite the $Desc, and post it back.

Consolewrite the $newString and post it back, also

 

Consolewrite ($Desc): 

285904MP
PM1163875
net worth performance displaying incorrect numbers.
 
ConsoleWrite($newString):
PM1163875
net worth performance displaying incorrect numbers.
Link to comment
Share on other sites

Here you go:

$string = "285904MP" & @CRLF & "PM1163875" & @CRLF & "net worth performance displaying incorrect numbers."

$aString = StringRegExp($string,"(PM\d{7})",3)
$newString=$aString[0]
ConsoleWrite($newString & @CRLF)

or:

$string = "285904MP" & @CRLF & "PM1163875" & @CRLF & "net worth performance displaying incorrect numbers."

$aString = StringRegExpReplace($string,"(?s).*(PM\d{7}).*","$1")
ConsoleWrite($aString & @CRLF)
Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

 

Here you go:

$string = "285904MP" & @CRLF & "PM1163875" & @CRLF & "net worth performance displaying incorrect numbers."

$aString = StringRegExp($string,"(PM\d{7})",3)
$newString=$aString[0]
ConsoleWrite($newString & @CRLF)

or:

$string = "285904MP" & @CRLF & "PM1163875" & @CRLF & "net worth performance displaying incorrect numbers."

$aString = StringRegExpReplace($string,"(?s).*(PM\d{7}).*","$1")
ConsoleWrite($aString & @CRLF)

 

You are amazing. It worked. :) Jus one hurdle. I am getting error if this PMxxxxx is not present in textbox. Is it possible to ignore and let the script run?

==> Subscript used on non-accessible variable.:
$newString1=$aString[0]
$newString1=$aString^ ERROR
Link to comment
Share on other sites

If IsArray($aString) Then

your code to add to excel

EndIf

 

This is my code:

$aString = StringRegExp($YodleeDesc,"(PMd{7})",3)
$newString1=$aString[0]
If IsArray($aString) Then
_ExcelWriteCell($oExcel, $newString1, $i, 3)
Else
_ExcelWriteCell($oExcel, "No Maximo#", $i, 3)
EndIf
 
and I am getting below error
 
==> Subscript used on non-accessible variable.:
$newString1=$aString[0]
$newString1=$aString^ ERROR
Link to comment
Share on other sites

If it's not an array, you can't assign a subscript to a variable...add that into the If statement, where it is an array.

$aString = StringRegExp($YodleeDesc,"(PM\d{7})",3)
 

 
If IsArray($aString) Then
$newString1=$aString[0] 
_ExcelWriteCell($oExcel, $newString1, $i, 3)
 
Else
 
_ExcelWriteCell($oExcel, "No Maximo#", $i, 3)
 
EndIf
Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

 

If it's not an array, you can't assign a subscript to a variable...add that into the If statement, where it is an array.

$aString = StringRegExp($YodleeDesc,"(PM\d{7})",3)
 

 
If IsArray($aString) Then
$newString1=$aString[0] 
_ExcelWriteCell($oExcel, $newString1, $i, 3)
 
Else
 
_ExcelWriteCell($oExcel, "No Maximo#", $i, 3)
 
EndIf

 

Hey jdelaney, it worked like a charm.. Thanks so much..

Can I take liberty to ask another question regarding same?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...