diff --git a/swan-lake/by-example/configuring-via-toml/content.jsx b/swan-lake/by-example/configuring-via-toml/content.jsx index c7c62c7f271..67af1656304 100644 --- a/swan-lake/by-example/configuring-via-toml/content.jsx +++ b/swan-lake/by-example/configuring-via-toml/content.jsx @@ -34,11 +34,17 @@ public function main() { io:println("admin details: ", admin); io:println("users: ", users); } +`, + `maxPayload = 3.21 +acceptTypes = ["application/xml", "application/json", "text/plain"] +admin = {username = "admin", password = "password"} +users = [{username = "John", password = "abc123"}, {username = "Bob", password = "cde456"}] `, ]; export function ConfiguringViaToml({ codeSnippets }) { const [codeClick1, updateCodeClick1] = useState(false); + const [codeClick2, updateCodeClick2] = useState(false); const [outputClick1, updateOutputClick1] = useState(false); const ref1 = createRef(); @@ -161,6 +167,95 @@ export function ConfiguringViaToml({ codeSnippets }) { +

+ To run the example, copy the following content to a file named{" "} + Config.toml in the current directory. +

+ + + + + {codeClick2 ? ( + + ) : ( + + )} + + + {codeSnippets[1] != undefined && ( +
+ )} + + + latinValue).substring()); + regexp:Span? findResult = pattern5.find("aεЛ"); + // The \`find\` function returns nil if no match is found. Since we know a + // match is found here, use the \`ensureType\` function to narrow the type down to \`regexp:Span\`. + regexp:Span latinValue = check findResult.ensureType(); + io:println("Pattern \`\\\\p{sc=Latin}\` matches \`aεЛ\`: ", latinValue.substring()); - // RegExp supports non-capturing groups to control the behavior of regular expression patterns. + // The \`RegExp\` type supports non-capturing groups to control the behavior of regular expression patterns. // The \`i\` flag will ignore the case of the pattern. string:RegExp pattern6 = re \`(?i:BalleRINA)\`; io:println("Pattern \`(?i:BalleRINA)\` matches \`Ballerina\`: ", "Ballerina".matches(pattern6)); @@ -79,9 +88,9 @@ export function RegexpType({ codeSnippets }) {

A RegExp value can be created by using the regexp template - expression or calling the fromString method of the{" "} + expression or calling the{" "} - lang.regexp + fromString method of the lang.regexp {" "} module.

@@ -224,6 +233,8 @@ export function RegexpType({ codeSnippets }) {
             
               {`\$ bal run regexp_type.bal`}
+              {`Pattern \`[a-zA-Z0-9]\` matches \`a\`: true`}
+              {`Pattern \`[a-zA-Z0-9]\` matches \`a1\`: false`}
               {`Pattern \`HELLO*\` matches \`HELLO\`: true`}
               {`Pattern \`a+\` matches \`aaa\`: true`}
               {`Pattern \`abc|\${"xyz"}\` matches \`xyz\`: true`}
@@ -263,7 +274,7 @@ export function RegexpType({ codeSnippets }) {
           • 
           
             
-              RegExp API Docs
+              regexp langlib API Docs
             
           
         
@@ -273,7 +284,17 @@ export function RegexpType({ codeSnippets }) {
           • 
           
             
-              string API Docs
+              string langlib API Docs
+            
+          
+        
+      
+