@@ -1228,6 +1228,134 @@ public static BooleanExpression regexContains(String fieldName, String pattern)
12281228 return regexContains (field (fieldName ), constant (pattern ));
12291229 }
12301230
1231+ /**
1232+ * Creates an expression that returns the first substring of a string expression that matches a
1233+ * specified regular expression.
1234+ *
1235+ * <p>This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression
1236+ * syntax.
1237+ *
1238+ * @param string The expression representing the string to search.
1239+ * @param pattern The regular expression to search for.
1240+ * @return A new {@link Expression} representing the regular expression find function.
1241+ */
1242+ @ BetaApi
1243+ public static Expression regexFind (Expression string , Expression pattern ) {
1244+ return new FunctionExpression ("regex_find" , ImmutableList .of (string , pattern ));
1245+ }
1246+
1247+ /**
1248+ * Creates an expression that returns the first substring of a string expression that matches a
1249+ * specified regular expression.
1250+ *
1251+ * <p>This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression
1252+ * syntax.
1253+ *
1254+ * @param string The expression representing the string to search.
1255+ * @param pattern The regular expression to search for.
1256+ * @return A new {@link Expression} representing the regular expression find function.
1257+ */
1258+ @ BetaApi
1259+ public static Expression regexFind (Expression string , String pattern ) {
1260+ return regexFind (string , constant (pattern ));
1261+ }
1262+
1263+ /**
1264+ * Creates an expression that returns the first substring of a string field that matches a
1265+ * specified regular expression.
1266+ *
1267+ * <p>This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression
1268+ * syntax.
1269+ *
1270+ * @param fieldName The name of the field containing the string to search.
1271+ * @param pattern The regular expression to search for.
1272+ * @return A new {@link Expression} representing the regular expression find function.
1273+ */
1274+ @ BetaApi
1275+ public static Expression regexFind (String fieldName , Expression pattern ) {
1276+ return regexFind (field (fieldName ), pattern );
1277+ }
1278+
1279+ /**
1280+ * Creates an expression that returns the first substring of a string field that matches a
1281+ * specified regular expression.
1282+ *
1283+ * <p>This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression
1284+ * syntax.
1285+ *
1286+ * @param fieldName The name of the field containing the string to search.
1287+ * @param pattern The regular expression to search for.
1288+ * @return A new {@link Expression} representing the regular expression find function.
1289+ */
1290+ @ BetaApi
1291+ public static Expression regexFind (String fieldName , String pattern ) {
1292+ return regexFind (field (fieldName ), constant (pattern ));
1293+ }
1294+
1295+ /**
1296+ * Creates an expression that evaluates to a list of all substrings in a string expression that
1297+ * match a specified regular expression.
1298+ *
1299+ * <p>This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression
1300+ * syntax.
1301+ *
1302+ * @param string The expression representing the string to search.
1303+ * @param pattern The regular expression to search for.
1304+ * @return A new {@link Expression} that evaluates to a list of matched substrings.
1305+ */
1306+ @ BetaApi
1307+ public static Expression regexFindAll (Expression string , Expression pattern ) {
1308+ return new FunctionExpression ("regex_find_all" , ImmutableList .of (string , pattern ));
1309+ }
1310+
1311+ /**
1312+ * Creates an expression that evaluates to a list of all substrings in a string expression that
1313+ * match a specified regular expression.
1314+ *
1315+ * <p>This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression
1316+ * syntax.
1317+ *
1318+ * @param string The expression representing the string to search.
1319+ * @param pattern The regular expression to search for.
1320+ * @return A new {@link Expression} that evaluates to a list of matched substrings.
1321+ */
1322+ @ BetaApi
1323+ public static Expression regexFindAll (Expression string , String pattern ) {
1324+ return regexFindAll (string , constant (pattern ));
1325+ }
1326+
1327+ /**
1328+ * Creates an expression that evaluates to a list of all substrings in a string field that match a
1329+ * specified regular expression.
1330+ *
1331+ * <p>This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression
1332+ * syntax.
1333+ *
1334+ * @param fieldName The name of the field containing the string to search.
1335+ * @param pattern The regular expression to search for.
1336+ * @return A new {@link Expression} that evaluates to a list of matched substrings.
1337+ */
1338+ @ BetaApi
1339+ public static Expression regexFindAll (String fieldName , Expression pattern ) {
1340+ return regexFindAll (field (fieldName ), pattern );
1341+ }
1342+
1343+ /**
1344+ * Creates an expression that evaluates to a list of all substrings in a string field that match a
1345+ * specified regular expression.
1346+ *
1347+ * <p>This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression
1348+ * syntax.
1349+ *
1350+ * @param fieldName The name of the field containing the string to search.
1351+ * @param pattern The regular expression to search for.
1352+ * @return A new {@link Expression} that evaluates to a list of matched substrings.
1353+ */
1354+ @ BetaApi
1355+ public static Expression regexFindAll (String fieldName , String pattern ) {
1356+ return regexFindAll (field (fieldName ), constant (pattern ));
1357+ }
1358+
12311359 /**
12321360 * Creates an expression that checks if a string field matches a specified regular expression.
12331361 *
@@ -3872,6 +4000,36 @@ public final BooleanExpression regexContains(Object pattern) {
38724000 return regexContains (this , toExprOrConstant (pattern ));
38734001 }
38744002
4003+ /**
4004+ * Creates an expression that returns the first substring of a string expression that matches a
4005+ * specified regular expression.
4006+ *
4007+ * <p>This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression
4008+ * syntax.
4009+ *
4010+ * @param pattern The regular expression to search for.
4011+ * @return A new {@link Expression} representing the regular expression find function.
4012+ */
4013+ @ BetaApi
4014+ public final Expression regexFind (Object pattern ) {
4015+ return regexFind (this , toExprOrConstant (pattern ));
4016+ }
4017+
4018+ /**
4019+ * Creates an expression that evaluates to a list of all substrings in a string expression that
4020+ * match a specified regular expression.
4021+ *
4022+ * <p>This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression
4023+ * syntax.
4024+ *
4025+ * @param pattern The regular expression to search for.
4026+ * @return A new {@link Expression} that evaluates to a list of matched substrings.
4027+ */
4028+ @ BetaApi
4029+ public final Expression regexFindAll (Object pattern ) {
4030+ return regexFindAll (this , toExprOrConstant (pattern ));
4031+ }
4032+
38754033 /**
38764034 * Creates an expression that checks if this string expression matches a specified regular
38774035 * expression.
0 commit comments