GetInQuotes: Get string from between quotes: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
No edit summary |
(→The Function: Fixed it so it will work with strings starting with a quote, like '"This is in quotes" This is not' (will return This is in quotes)) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{PageAuthor|Afrow UK}} | |||
== Description == | == Description == | ||
This function was written for [[zukex]] in [http://forums.winamp.com/showthread.php?postid=1719092 this forum topic]. It takes a string from between quotes in another string. If no paired quotes are found, the function will return an empty string. | This function was written for [[User:zukex|zukex]] in [http://forums.winamp.com/showthread.php?postid=1719092 this forum topic]. It takes a string from between quotes in another string. If no paired quotes are found, the function will return an empty string. | ||
== Usage == | == Usage == | ||
<highlight-nsis> | |||
Push 'a string containing "quotes"!' | Push 'a string containing "quotes"!' | ||
Call GetInQuotes | Call GetInQuotes | ||
Pop $R0 ; = quotes | Pop $R0 ; = quotes</highlight-nsis> | ||
== The Function == | == The Function == | ||
Line 18: | Line 21: | ||
Push $R3 | Push $R3 | ||
StrCpy $R2 | StrCpy $R2 -1 | ||
IntOp $R2 $R2 + 1 | IntOp $R2 $R2 + 1 | ||
StrCpy $R3 $R0 1 $R2 | StrCpy $R3 $R0 1 $R2 | ||
Line 48: | Line 51: | ||
-Stu | -Stu | ||
[[Category:String Functions]] |
Latest revision as of 09:10, 6 October 2006
Author: Afrow UK (talk, contrib) |
Description
This function was written for zukex in this forum topic. It takes a string from between quotes in another string. If no paired quotes are found, the function will return an empty string.
Usage
Push 'a string containing "quotes"!' Call GetInQuotes Pop $R0 ; = quotes
The Function
Function GetInQuotes Exch $R0 Push $R1 Push $R2 Push $R3 StrCpy $R2 -1 IntOp $R2 $R2 + 1 StrCpy $R3 $R0 1 $R2 StrCmp $R3 "" 0 +3 StrCpy $R0 "" Goto Done StrCmp $R3 '"' 0 -5 IntOp $R2 $R2 + 1 StrCpy $R0 $R0 "" $R2 StrCpy $R2 0 IntOp $R2 $R2 + 1 StrCpy $R3 $R0 1 $R2 StrCmp $R3 "" 0 +3 StrCpy $R0 "" Goto Done StrCmp $R3 '"' 0 -5 StrCpy $R0 $R0 $R2 Done: Pop $R3 Pop $R2 Pop $R1 Exch $R0 FunctionEnd
-Stu