You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/user-docs/handlebars.md
+55-1Lines changed: 55 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -928,6 +928,8 @@ This would result in:
928
928
929
929
The `regexFindFirst` helper will take the input regular expression and return the first matching substring from the supplied string. Will return `""` otherwise.
930
930
931
+
> The regular expression syntax that Javascript supports is a bit different from other languages, please refer to [MDN regular expressions document](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) for more information.
932
+
931
933
A simple example where we try to match the file extension `jpg` or `png` with testString="jumpng-fox.jpg":
You can also use the `flags` named optional argument to pass [regular expression flags](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#advanced_searching_with_flags). For example you can use the `i` flag for case-insensitive searching:
> If `flags` argument is not used, by default we are using the `g` (global search) flag for the regular expression search.
951
959
952
960
### Findall helper
953
961
954
962
The `regexFindAll` helper will take the input regular expression and return all the matching substrings from the supplied string in an array. Will return `[]` otherwise.
955
963
964
+
> The regular expression syntax that Javascript supports is a bit different from other languages, please refer to [MDN regular expressions document](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) for more information.
965
+
956
966
A simple example where we try to match the file extension `jpg` or `png` with testString="jumpng-fox.jpg":
You can also use the `flags` named optional argument to pass [regular expression flags](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#advanced_searching_with_flags). For example you can use the `i` flag for case-insensitive searching:
> If `flags` argument is not used, by default we are using the `g` (global search) flag for the regular expression search.
982
+
966
983
### Replace helper
967
984
968
-
The `replace` helper will take the input regular expression (first argument) and replace all matches in the supplied string with the supplied substring (second argument). This helper behaves the same way as the `replace` function for Strings in javascript. One example would be to replace all underscores with whitespace characters for table name display.
985
+
The `replace` helper will take the input regular expression (first argument) and replace all matches in the supplied string with the supplied substring (second argument). This helper behaves the same way as the `replace` function for Strings in javascript.
986
+
987
+
> The regular expression syntax that Javascript supports is a bit different from other languages, please refer to [MDN regular expressions document](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) for more information.
988
+
989
+
One example would be to replace all underscores with whitespace characters for table name display.
969
990
970
991
Template:
971
992
```
@@ -977,6 +998,30 @@ Result:
977
998
table name with underscores
978
999
```
979
1000
1001
+
You can also use the `flags` named optional argument to pass [regular expression flags](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#advanced_searching_with_flags). By default we're using the `g` flag, that's why the example above is replacing all the matches. Examples of using the `flags` named argument:
1002
+
1003
+
- If you only want to replace the first match, you can pass empty string for flags:
- Result (assuming `Gene_Names` is `"Aco1, ACO1"`):
1021
+
```
1022
+
ACO1, ACO1
1023
+
```
1024
+
980
1025
### ToTitleCase helper
981
1026
982
1027
The `toTitleCase` helper will change the first character of each word (split by whitespace) in the string to a capital letter. The rest of the case of the string will remain unchanged.
@@ -1056,6 +1101,15 @@ Using the `regexMatch` function you can check whether a given value matches the
1056
1101
{{/if}}
1057
1102
```
1058
1103
1104
+
You can also use the `flags` named optional argument to pass [regular expression flags](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#advanced_searching_with_flags). For example you can use the `i` flag for case-insensitive matching:
1105
+
```
1106
+
{{#if (regexMatch value "film analysis" flags="i" )}}
1107
+
.. content
1108
+
{{/if}}
1109
+
```
1110
+
1111
+
> If `flags` argument is not used, by default we are using the `g` (global search) flag for the regular expression search.
0 commit comments