Created
November 9, 2018 08:00
-
-
Save trycf/93a8906a03115a5d469085c30e6aefdc to your computer and use it in GitHub Desktop.
TryCF Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- 正規表現で部分文字列を取得する関数 ---> | |
<CFFUNCTION name="REArray" returntype="array"> | |
<CFARGUMENT name="reg_ex" type="string" required="true"> | |
<CFARGUMENT name="target_str" type="string" required="true"> | |
<CFSET local.regex = REFindNoCase(reg_ex, target_str, 1, true)> | |
<CFSET local.aResult = arrayNew(1)> | |
<CFLOOP from="1" to="#arrayLen(local.regex.pos)#" index="i"> | |
<CFIF local.regex.pos[i] neq 0> | |
<CFSET arrayAppend(local.aResult, mid(target_str, local.regex.pos[i], local.regex.len[i]))> | |
</CFIF> | |
</CFLOOP> | |
<CFRETURN local.aResult> | |
</CFFUNCTION> | |
<CFSET aResult = REArray("^【(\d+)月(\d+)日.+】(.+)おまかせ御膳((.+))$", "【8月30日(木)】雑穀米220gおまかせ御膳(海老チリ&シューマイ)")> | |
<CFDUMP var="#aResult#"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment