GetInQuotes: Get string from between quotes: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
Line 8: Line 8:
Push 'a string containing "quotes"!'
Push 'a string containing "quotes"!'
Call GetInQuotes
Call GetInQuotes
Pop $R0 ; = quotes
Pop $R0 ; = quotes</highlight-nsis>
</highlight-nsis>


== The Function ==
== The Function ==

Revision as of 23:50, 2 July 2005

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