# Problem with RegEx inside loop.

## Recommended Posts

The function below works but I can't seem to iterate from 0 to 9 without the regexp check returning false. I thought that it might be a bug. I've tried putting it inside a loop where the digit would be replaced with the string below with

Replacement: " & \$i & "

So that during each iteration....but it fails?

I didn't want to mention that Regular Expressions could be part of the problems equation in the topic's title. Thanks for your help

```Func _TrimAfterYear(\$sTest)
Local \$aMatch = StringRegExp(\$sTest, "d{4}", 1)
If IsArray(\$aMatch) Then
Local \$iPos = StringInStr(\$sTest, \$aMatch[0]) + 3
Local \$sPart = StringMid(\$sTest, \$iPos)
If StringRegExp(\$sPart, "(?i)(pt 2)|(pt2)|(part2)|(part 2)|(cd2)|(cd 2)", 0) Then
\$sPart = " Part 2"
ElseIf StringRegExp(\$sPart, "(?i)(pt 1)|(pt1)|(part1)|(part 1)|(cd1)|(cd 1)", 0) Then
\$sPart = " Part 1"
ElseIf StringRegExp(\$sPart, "(?i)(pt 0)|(pt0)|(part0)|(part 0)|(cd0)|(cd 0)", 0) Then
\$sPart = " Part 0"
ElseIf StringRegExp(\$sPart, "(?i)(pt 3)|(pt3)|(part3)|(part 3)|(cd3)|(cd 3)", 0) Then
\$sPart = " Part 3"
ElseIf StringRegExp(\$sPart, "(?i)(pt 4)|(pt4)|(part4)|(part 4)|(cd4)|(cd 4)", 0) Then
\$sPart = " Part 4"
ElseIf StringRegExp(\$sPart, "(?i)(pt 5)|(pt5)|(part5)|(part 5)|(cd5)|(cd 5)", 0) Then
\$sPart = " Part 5"
Else
\$sPart = ""
EndIf
Return StringTrimRight(\$sTest, StringLen(\$sTest) - \$iPos) & \$sPart
Else
Local \$aInfo = _IMDB_Search(\$sTest)
If IsArray(\$aInfo) Then
If \$aInfo[1][1] <> "" Then \$sTest &= " " & \$aInfo[1][1]
EndIf
Return \$sTest
EndIf
EndFunc ;==>_TrimAfterYear```

*Edit

The above function is used to format filenames.

If I was to run this string ("Wanted 2008 anything after it") through this function then the "anything after it"

would be removed. This can be problematic if I were to run lets say two files that have identical names aside from the named number suffix "cd1, cd2, part1, part2" and so on.

i.e. A video split in half - The Avengers 2012 cd1 and The Avengers 2012 cd2 once the file names were run through this function they both would return as "The Avengers 2012." + extension. If you use AutoIt's renaming function - FileMove with the overwrite param than BAM! you overwrite one of the files thus reason to include defensive programming. Like I said the function works but I'd rather do the RegEx check inside of a loop because it requires less lines of code and is neat aka tidy folks. When using known method to attempt at making this process iterative the RegEx will fail. Try it, Buy It than take it back because its the same test string using different digits referenced by variables. If this isn't a bug or limitation than I'm confused.

Edited by Decipher
Spoiler

##### Share on other sites

The title should have been Iterative problem with function.

```Func _TrimAfterYear(\$sTest)
Local \$aMatch = StringRegExp(\$sTest, "d{4}", 1)
If IsArray(\$aMatch) Then
Local \$iPos = StringInStr(\$sTest, \$aMatch[0]) + 3
Local \$sPart = StringMid(\$sTest, \$iPos)
For \$i = 1 To 10
If StringRegExp(\$sPart, "(?i)(pt " & \$i & ")|(pt" & \$i & ")|(part" & \$i & ")|(part " & \$i & ")|(cd" & \$i & ")|(cd " & \$i & ")", 0) Then
\$sPart = " Part " & \$i
ExitLoop
Else
\$sPart = ""
EndIf
Next
Return StringTrimRight(\$sTest, StringLen(\$sTest) - \$iPos) & \$sPart
Else
Return \$sTest
EndIf
EndFunc ;==>_TrimAfterYear```

The function should rename "anything 2012 cd1" to "anything 2012 Part 1"

Edited by Decipher
Spoiler

##### Share on other sites

• Moderators

Dechipher,

The edit the first post and select the "Use Full Editor]" option - that opens the title for editing as well.

m23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

##### Share on other sites

Thanks again. I quess you don't scan all new posts and topics for your name then....

Edited by Decipher
Spoiler

##### Share on other sites

• Moderators

Decipher,

I quess you don't scan all new posts and topics for your name then....

No, I use a much more sophisticated algorithm than that.

M23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

##### Share on other sites

• Moderators

Decipher,

Looking at the question you posed I am still unsure what it is you are trying to do. The example you give:

The function should rename "anything 2012 cd1" to "anything 2012 Part 1"

can be solved with a simple StringReplace.

Can you give us a list with examples of all the likely names and what you want them to be converted into afterwards - then we can work up a suitable pattern for a RegEx.

M23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

##### Share on other sites

It may not always be "cd1" that needs to be replaced. The following strings could be present:

(cd, pt, part) Naming Conventions. I'm trying to make it comprehensive. There could be either a space between the "cd" and digit or not.

Consider the following file names:

*Edit

cd1, cd 1, pt 1, pt1, part1, part 1 where 1 could be any singe digit.

*End of Edit

Ice Age 4 Continental Drift 2012 xvid avi 1080p ac3 part 1.avi - Result: Ice Age 4 Continental Drift 2012 Part 1.avi

Ice Age 4 Continental Drift 2012 xvid avi 1080p ac3 part 2.avi - Result: Ice Age 4 Continental Drift 2012 Part 1.avi

John Carter 2012 bluray 720p aad bla cd1.avi - Result: John Carter 2012 Part 1.avi

John Carter 2012 bluray 720p aad bla cd2.avi - Result: John Carter 2012 Part 2.avi

Ramona And Beezus 2010 bluray 720p aad bla pt 1.avi - Result: Ramona And Beezus 2010 Part 1.avi

Ramona And Beezus 2010 bluray 720p aad bla pt 2.avi - Result: Ramona And Beezus 2010 Part 2.avi

If I remove everything after the year than the "pt2" suffix would be removed also. I need to check for that so I won't overwrite the

previous file that also has the same name.

The functions above check to see if there a 4 digits in the string if so it finds the position of the alleged year and removes everything after it. I won't to detect if there is a "part " & \$Digit in the filename before this happens than after the trim add it back.

Edited by Decipher
Spoiler

##### Share on other sites

• Moderators

Decipher,

Not too hard:

```Global \$aList[8] = ["Ice Age 4 Continental Drift 2012 xvid avi 1080p ac3 part 1.avi", _
"Ice Age 4 Continental Drift 2012 xvid avi 1080p ac3 part 2.avi", _
"John Carter 2012 bluray 720p aad bla cd1.avi", _
"John Carter 2012 bluray 720p aad bla cd2.avi", _
"John Carter 2012 bluray 720p aad bla cd 1.avi", _
"John Carter 2012 bluray 720p aad bla cd 2.avi", _
"Ramona And Beezus 2010 bluray 720p aad bla pt 1.avi", _
"Ramona And Beezus 2010 bluray 720p aad bla pt 2.avi"]

For \$i = 0 To 7
\$sNew_Name = StringRegExpReplace(\$aList[\$i], "(?i)(?U)(.*dddd).*(part|pt|cd)s?(d)(..*)", "\$1 Part \$3\$4")
ConsoleWrite(\$sNew_Name & @CRLF)
Next```

SRER decode:

```(?i)         - Case Insensitive
(?U)         - Not greedy
(.*dddd) - Capture all characters up to and including 4 digits - this should be the date = stored as \$1
.*           - Ignore all characters up to
(part|pt|cd) - Capture either of these possibilities                                         = stored as \$2
s?          - Ignore a possible space
(d)         - Capture the next digit                                                        = stored as \$3
(..*)       - Capture a dot and any following characters                                    = stored as \$4

Replace with
\$1 Part \$3\$4 - Recreate using the stored parts and some free text```

We need the (?U) as you have the "1080" in some of the original titles and so we need to look for the first instance (presumably the date) and not the last instance of 4 digits.

All clear?

M23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Melba23,

Yes, perfectly

Thanks

Spoiler

##### Share on other sites

Could a SRER be written to replace this function as well?

```Func _FirstLetterCapitals(\$sTest)
Local \$sFirstChar
If StringRegExp(\$sTest, "\s") Then
Local \$aMatch = StringSplit(\$sTest, " ")
For \$iString = 1 To \$aMatch[0] Step 1
If \$aMatch[\$iString] <> "" Then
\$sFirstChar = StringMid(\$aMatch[\$iString], 1, 1)
If StringRegExp(\$sFirstChar, "[a-z]", 0) Then
\$aMatch[\$iString] = StringReplace(\$aMatch[\$iString], StringLower(\$sFirstChar), StringUpper(\$sFirstChar), 1)
EndIf
EndIf
Next
Return _ArrayToString(\$aMatch, " ", 1)
Else
\$sFirstChar = StringMid(\$sTest, 1, 1)
Return StringReplace(\$sTest, StringLower(\$sFirstChar), StringUpper(\$sFirstChar), 1)
EndIf
EndFunc ;==>_FirstLetterCapitals```

Function capitalizes the first letter in all words contained in a string. I know I'm just being greedy now

A simple yes of no will suffice. Thanks.

Edited by Decipher
Spoiler

##### Share on other sites

• Moderators

Decipher,

Have you looked at _StringProper in the Help file?

M23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

##### Share on other sites

Decipher,

Look at function stringproper in help file.

kylomas

edit: too quick, M23...giong to school on that SRER you wrote!

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

##### Share on other sites

LOL, Thanks guies.

*Edit I replaced my function with _StringProper with negative results.

Video: Madea's Witness Protection Program PT2 698 MB Type: AVI

!>Moved: "Madea'S Witness Protection Program Pt2.avi" to F:VideoAVI

Just incase anyone ever has a use for the function.

Edited by Decipher
Spoiler

##### Share on other sites

If you want a Title (or Start) Case function, and not a Proper function, this is probably more to your liking. Doesn't work well with Unicode in all cases.

```\$String = "'she's all 'that' I,wAnt(" & '1st "disk" of 2)'
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : _StringTitleCase(\$String) = ' & _StringTitleCase(\$String) & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

; #FUNCTION# ====================================================================================================================
; Name...........: _StringTitleCase
; Description ...: Changes a string to title case
; Syntax.........: _StringTitleCase(\$s_String)
; Parameters ....: \$s_String - Input string
; Return values .: Success - Returns titlecased string.
; Failure - Returns "".
; Author ........: Jos van der Zande <jdeb at autoitscript dot com>
; Modified.......: BrewManNH
; Remarks .......: This function will capitalize the first character of every word. Modified _StringProper to a titlecase
; function instead of a Proper function. Not Unicode compatible.
; Related .......: _StringProper
; Example .......: Yes
; ===============================================================================================================================
Func _StringTitleCase(\$s_String) ; modified _StringProper function, correctly capitalizes after ' and numbers
Local \$iX = 0
Local \$CapNext = 1
Local \$s_nStr = ""
Local \$s_CurChar
For \$iX = 1 To StringLen(\$s_String)
\$s_CurChar = StringMid(\$s_String, \$iX, 1)
Select
Case \$CapNext = 1
If StringRegExp(\$s_CurChar, "[a-zA-ZxC0-xFF0-9]") Then
\$s_CurChar = StringUpper(\$s_CurChar)
\$CapNext = 0
EndIf
Case Not StringRegExp(\$s_CurChar, "[a-zA-ZxC0-xFF'0-9]")
\$CapNext = 1
Case Else
\$s_CurChar = StringLower(\$s_CurChar)
EndSelect
\$s_nStr &= \$s_CurChar
Next
Return \$s_nStr
EndFunc ;==>_TitleCaseString```

If you use _StringProper with words with apostrophes (Joe's, they're, etc.), the capitalization is a little odd looking.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

##### Share on other sites

BrewManNH,

Thanks, I'll be using that function for sure.

Spoiler

##### Share on other sites

Any ideas why the RegEx check fails when inside a loop and the digits repaced with a variable? In my initial post the function works but the latter dosen't. Not that it really matters now.

Spoiler

##### Share on other sites

• Moderators

Decipher,

This modified version using a varible works fine for me:

```Global \$aList[8] = ["Ice Age 4 Continental Drift 2012 xvid avi 1080p ac3 part 1.avi", _
"Ice Age 4 Continental Drift 2012 xvid avi 1080p ac3 part 2.avi", _
"John Carter 2012 bluray 720p aad bla cd1.avi", _
"John Carter 2012 bluray 720p aad bla cd2.avi", _
"John Carter 2012 bluray 720p aad bla cd 1.avi", _
"John Carter 2012 bluray 720p aad bla cd 2.avi", _
"Ramona And Beezus 2010 bluray 720p aad bla pt 1.avi", _
"Ramona And Beezus 2010 bluray 720p aad bla pt 2.avi"]

For \$i = 0 To 7
\$sNew_Name = _TrimAfterYear(\$aList[\$i])
ConsoleWrite(\$sNew_Name & @CRLF)
Next

Func _TrimAfterYear(\$sTest)
Local \$aMatch = StringRegExp(\$sTest, "d{4}", 1)
If IsArray(\$aMatch) Then
Local \$iPos = StringInStr(\$sTest, \$aMatch[0]) + 3
Local \$sPart = StringMid(\$sTest, \$iPos)
For \$i = 0 To 5
If StringRegExp(\$sPart, "(?i)(pt |pt|part|part |cd|cd )" & \$i) Then
\$sPart = " Part " & \$i
ExitLoop
EndIf
Next
Return StringTrimRight(\$sTest, StringLen(\$sTest) - \$iPos) & \$sPart
Else
Local \$aInfo = _IMDB_Search(\$sTest)
If IsArray(\$aInfo) Then
If \$aInfo[1][1] <> "" Then \$sTest &= " " & \$aInfo[1][1]
EndIf
Return \$sTest
EndIf
EndFunc   ;==>_TrimAfterYear```

You can shorten the RegEx to this if you separate out the optional space:

`StringRegExp(\$sPart, "(?i)(pt|part|cd)s?" & \$i)`

M23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

##### Share on other sites

One more question please. If I use this

`\$sTest = StringRegExpReplace("Alphas S02E02 Part 1", "(?i)(part|pt|cd)s?(d)|(?i)(s(d){2})(e(d){2})", "")`
to remove "S02E02 Part 1" to perform a IMDB lookup for the missing year using the string "Alphas" than why when I use

`\$aMatch = StringRegExp(\$sTest, "(?i)(part|pt|cd)s?(d)|(?i)(s(d){2})(e(d){2})", 1)`
to store the "S02E02 Part 1" beforehand to be restored after the search and after the addition of the year, will the array only contain:

[0]|

[1]|

[2]|S02

[3]|2

[4]|E02

[5]|2

Which is missing "Part 1" and contains two extra digits where the output becomes: "Alphas 2011 S02 2 E02 2"

```_TrimAfterYear("Alphas S02E02 part 1")
Exit

Func _TrimAfterYear(\$sTest)
If Not StringRegExp(\$sTest, "(.*dddd)") Then
Local \$aMatch = StringRegExp(\$sTest, "(?i)(part|pt|cd)s?(d)|(?i)(s(d){2})(e(d){2})", 1)
If Not @error Then
\$sTest = StringRegExpReplace(\$sTest, "(?i)(part|pt|cd)s?(d)|(?i)(s(d){2})(e(d){2})", "")
_ArrayDisplay(\$aMatch)
MsgBox(0, "", \$sTest)
EndIf
Local \$aInfo = _IMDB_Search(\$sTest)
If \$aInfo[1][1] <> "" Then
\$sTest &= \$aInfo[1][1]
If IsArray(\$aMatch) Then \$sTest &= " " & _ArrayToString(\$aMatch, " ")
ConsoleWrite( \$sTest)
EndIf
EndIf
Return StringRegExpReplace(\$sTest, "(?i)(?U)(.*dddd).*(part|pt|cd)s?(d)(..*)", "\$1 Part \$3\$4")
EndFunc   ;==>_TrimAfterYear

Func _IMDB_To_Array(\$sString)
Local \$sStart_Suffix = ':"', \$sDelim = '"', \$aTemp_Array
Local \$aInfo[4][2] = [["Title", ''],["Year", ''],["Plot", ''],["Poster", '']]
For \$i = 0 To 3
If \$i = 3 Then
\$aTemp_Array = _StringBetween(\$sString, 'http://', '.jpg')
If IsArray(\$aTemp_Array) Then \$aInfo[\$i][1] = 'http://' & \$aTemp_Array[0] & '.jpg'
ContinueLoop
EndIf
\$aTemp_Array = _StringBetween(\$sString, \$aInfo[\$i][0] & \$sDelim & \$sStart_Suffix, \$sDelim)
If IsArray(\$aTemp_Array) Then \$aInfo[\$i][1] = \$aTemp_Array[0]
Next
Return \$aInfo
EndFunc ;==>_IMDB_To_Array

Func _IMDB_Search(\$sEncoded_String)
Local \$sSearchData = _GetSourceCode("http://omdbapi.com/?t=" & \$sEncoded_String)
If \$sSearchData = "" Then
Return SetError(1, 0, 0)
Else
;MsgBox(0, "", \$sSearchData, 1)
Return _IMDB_To_Array(\$sSearchData)
EndIf
EndFunc ;==>_IMDB_Search

Func _GetSourceCode(\$sUrl)
Endfunc```
Edited by Decipher
Spoiler

##### Share on other sites

• Moderators

Decipher,

You really need a class in "How to ask a question", because you certainly do not make your requests clear at present!

A general point: the first question you need to ask is "Do I need an SRE to do this?". SREs are powerful, but are not the answer to every problem - as their name suggests you do need some form of pattern to use them and often there is not one.

Now turning to your post: do you have many names with the "S02E02 Part 1" ending - or is it just this one? If there are many then we can work on an SRE - if it is just this one then simpler String* functions are probably better suited. And why are you getting the SRE to return an array where you want a string?

Ready to help when I can get some sensible information on which to work.

M23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

##### Share on other sites

Melba23,

What RegEx would I use to match "S01E01"?

How can I return the matched string as a string.

Edited by Decipher
Spoiler

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
×
• Create New...