/****************************************************************************** * Copyright (c) 2000-2019 Ericsson Telecom AB * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html ******************************************************************************/ /////////////////////////////////////////////////////////////////////////////// // // File: TCCRegexp_Example.ttcn // Description: TCC Useful Functions: Regular Expression Functions. // Rev: R36B // Prodnr: CNL 113 472 // Contact: http://ttcn.ericsson.se /////////////////////////////////////////////// module TCCRegexp_Example { import from TCCRegexp_Functions all; type component Test_CT{} testcase tc_1() runs on Test_CT { var charstring vl_subject := "a :1 2\nb:1 2\na :2 3"; var charstring vl_pattern := "a :(\\d+) (\\d+)"; var integer vl_groupno := 0; var charstring vl_expected := "a :1 2"; var charstring vl_result := f_pcre_regexp(vl_subject, vl_pattern, vl_groupno); log(vl_result); if(vl_result == vl_expected) {setverdict(pass)} else {setverdict(fail)} var charstring_list vl_expected2 := {"a :1 2", "1", "2"}; var charstring_list vl_result2 := f_pcre_regexp_list(vl_subject, vl_pattern); log(vl_result2) if(vl_result2 == vl_expected2) {setverdict(pass)} else {setverdict(fail)} var t_list_of_charstring_list vl_expected3 := {{"a :1 2", "1", "2"},{"a :2 3", "2", "3"}}; var t_list_of_charstring_list vl_result3 := f_pcre_regexp_list_all_matches(vl_subject, vl_pattern); log(vl_result3) if(vl_result3 == vl_expected3) {setverdict(pass)} else {setverdict(fail)} } control { execute(tc_1()) } }