구문
인수
설명
text
(필수) 검색할 텍스트입니다. 와일드카드 문자는 사용할 수 없습니다. 텍스트가 빈 문자열일 경우, 빈 텍스트를 반환합니다.“text”와 같은 문자열을 입력하거나, “C4”와 같은 셀 참조, 또는 “C4:D4”와 같은 셀 범위 참조를 입력할 수 있습니다 (동적 배열에서 작동).
pattern
(필수) 이 식과 일치하는 텍스트의 첫 번째 부분이 반환됩니다.“[0-9]+”와 같은 문자열을 입력하거나, “C4”와 같은 셀 참조를 입력할 수 있습니다.
return_mode
추출할 문자열의 위치를 지정하는 숫자입니다.0: (기본값) 패턴과 일치하는 첫 번째 문자열을 반환합니다.1: 패턴과 일치하는 모든 문자열을 배열로 반환합니다.2: 첫 번째 일치 항목에서 캡처 그룹을 배열로 반환합니다.
case_sensitivity
일치 여부를 대소문자를 구분하여 결정합니다.0: (기본값) 대소문자 구분.1: 대소문자 무시.
동적 배열
allowDynamicArray가 false로 설정된 경우에도 REGEXEXTRACT는 작동합니다. 하지만 일부 경우에는 최적의 결과를 위해 allowDynamicArray를 true로 설정해야 할 수 있습니다.
아래 예제에서 allowDynamicArray 플래그가 false일 경우 결과는 "Luve"이며, 플래그가 true일 경우 결과는 ["Luve", "rose"]가 됩니다.
예제
<template>
<div class="sample-tutorial">
<gc-spread-sheets class="sample-spreadsheets" @workbookInitialized="initSpread">
<gc-worksheet>
</gc-worksheet>
</gc-spread-sheets>
<div class="options-container">
<div class="option-row">
<label class="colorLabel">Switch the allowDynamicArray flag.</label>
</div>
<div class="option-row">
<input type="checkbox" id="allowDynamicArray" checked @change="changeFlag($event)" />
<label for="allowDynamicArray">Allow Dynamic Array</label>
</div>
</div>
</div>
</template>
<script setup>
import '@mescius/spread-sheets-vue';
import { ref } from "vue";
import GC from '@mescius/spread-sheets';
import '@mescius/spread-sheets-resources-ko';
GC.Spread.Common.CultureManager.culture("ko-kr");
const spreadRef = ref(null);
let initSpread = function (spread) {
spreadRef.value = spread;
spread.suspendPaint();
spread.options.allowDynamicArray = true;
let sheet = spread.sheets[0];
let defaultStyle = new GC.Spread.Sheets.Style();
defaultStyle.hAlign = GC.Spread.Sheets.HorizontalAlign.center;
defaultStyle.vAlign = GC.Spread.Sheets.VerticalAlign.center;
sheet.setDefaultStyle(defaultStyle);
sheet.setColumnWidth(0, 220);
sheet.setColumnWidth(1, 220);
sheet.setColumnWidth(2, 120);
sheet.setColumnWidth(3, 130);
sheet.setColumnWidth(4, 170);
sheet.setColumnWidth(5, 80);
sheet.setColumnWidth(6, 80);
sheet.addSpan(0, 0, 2, 1);
sheet.addSpan(0, 1, 2, 1);
sheet.addSpan(0, 2, 2, 1);
sheet.addSpan(0, 3, 2, 1);
sheet.addSpan(0, 4, 2, 1);
sheet.addSpan(0, 5, 2, 2);
sheet.getCell(0, 0).value("Text").font("21px bold normal normal");
sheet.getCell(0, 1).value("Regular Expression").font("21px bold normal normal");
sheet.getCell(0, 2).value("Return Mode").font("21px bold normal normal");
sheet.getCell(0, 3).value("Case Sensitivity").font("21px bold normal normal");
sheet.getCell(0, 4).value("Formula Text").font("21px bold normal normal");
sheet.getCell(0, 5).value("Result").font("21px bold normal normal");
let dataArr = [ ["I think SpreadJS is Good", "(good)", "", 1],
["there is 300 rabbits grazing", "\\d+", ""],
["O my Luve is like a red, red rose", "O my (\\w+) is like a red, red (\\w+)", 2]];
sheet.setArray(2, 0, dataArr);
for (let i = 0, len = dataArr.length; i < len; i++) {
let row = 3 + i;
sheet.setFormula(row - 1, 5, `=REGEXEXTRACT(A${row}, B${row}, C${row}, D${row})`);
sheet.setFormula(row - 1, 4, `=FORMULATEXT(F${row})`);
}
spread.resumePaint();
}
let changeFlag = function (e) {
let spread = spreadRef.value;
let checked = e.target.checked;
spread.options.allowDynamicArray = !!checked;
spread.resumeCalcService();
spread.resumePaint();
}
</script>
<style scoped>
#app {
height: 100%;
}
.sample-tutorial {
position: relative;
height: 100%;
overflow: hidden;
}
.sample-spreadsheets {
width: calc(100% - 280px);
height: 100%;
overflow: hidden;
float: left;
}
.options-container {
float: right;
width: 280px;
padding: 12px;
height: 100%;
box-sizing: border-box;
background: #fbfbfb;
overflow: auto;
}
.option-row {
margin-bottom: 12px;
}
label {
user-select: none;
}
body {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
</style>
<!DOCTYPE html>
<html style="height:100%;font-size:14px;">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>SpreadJS VUE</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css"
href="$DEMOROOT$/ko/vue3/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css">
<script src="$DEMOROOT$/ko/vue3/node_modules/systemjs/dist/system.src.js"></script>
<script src="./systemjs.config.js"></script>
<script src="./compiler.js" type="module"></script>
<script>
var System = SystemJS;
System.import("./compiler.js").then(() => {
System.import("./src/app.js");
});
System.import('$DEMOROOT$/ko/lib/vue3/license.js');
</script>
</head>
<body>
<div id="app"></div>
</body>
</html>
(function (global) {
SystemJS.config({
transpiler: 'plugin-babel',
babelOptions: {
es2015: true
},
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
packageConfigPaths: [
'./node_modules/*/package.json',
"./node_modules/@mescius/*/package.json",
"./node_modules/@babel/*/package.json",
"./node_modules/@vue/*/package.json"
],
map: {
'vue': "npm:vue/dist/vue.esm-browser.js",
'tiny-emitter': 'npm:tiny-emitter/index.js',
'plugin-babel': 'npm:systemjs-plugin-babel/plugin-babel.js',
"systemjs-babel-build": "npm:systemjs-plugin-babel/systemjs-babel-browser.js",
'@mescius/spread-sheets': 'npm:@mescius/spread-sheets/index.js',
'@mescius/spread-sheets-resources-ko': 'npm:@mescius/spread-sheets-resources-ko/index.js',
'@mescius/spread-sheets-vue': 'npm:@mescius/spread-sheets-vue/index.js'
},
meta: {
'*.css': { loader: 'systemjs-plugin-css' },
'*.vue': { loader: "../plugin-vue/index.js" }
}
});
})(this);