Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trycf/93a8906a03115a5d469085c30e6aefdc to your computer and use it in GitHub Desktop.
Save trycf/93a8906a03115a5d469085c30e6aefdc to your computer and use it in GitHub Desktop.
TryCF Gist
<!--- 正規表現で部分文字列を取得する関数 --->
<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