Jump to content

want to search within a string


Recommended Posts

Hi guys! Me thinking of a way to search within a string for a specific text and then copy all characters before the found text like:

as For Example

I have

$title = "XXXXXXXXXXXXXXXXXXXXXX(theses X's can change in number).doc Microsoft Word"

now i want to search within $title and then want to get the text before .doc.....Please keep this in mind that after .doc i sometimes face cases when there is (Read Only) which means that i can't do anything based on fixed length before and after .doc

Me simply want to copy all the text before .doc to a string. So i can use that later

Link to comment
Share on other sites

Use something like

#include <array.au3>
$title = "XXXXXXXXXXXXXXXXXXXXXX(theses X's can change in number).doc Microsoft Word"
$aSplitTitle = StringSplit($title, ".doc", 1)
_ArrayDisplay($aSplitTitle)

$aSplitTitle[1] will contain the required text.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thanks GUYS. Well both ways are working.

But want to ask something more about both.

#include <array.au3> 
$title = "XXXXXXXXXXXXXXXXXXXXXX(theses X's can change in number).doc Microsoft Word" 
$aSplitTitle = StringSplit($title, ".doc", 1) 
_ArrayDisplay($aSplitTitle)
;IF HERE i type MsgBox (0, "Patient List", $aSplitTitle) then it don't display any value

And some confusion about the second one.

Please can you point where can i read information about this (?i)(.*)(?:\.doc.*) I mean i want to read something about the usage of these wild cards.

Link to comment
Share on other sites

;IF HERE i type MsgBox (0, "Patient List", $aSplitTitle) then it don't display any value

StringSplit returns an array so you have to change the statement to:

MsgBox (0, "Patient List", $aSplitTitle[1])

Please can you point where can i read information about this (?i)(.*)(?:\.doc.*) I mean i want to read something about the usage of these wild cards.

This is a regular expression pattern. Please see "StringRegExp" in the help file or here for more details. Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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...