function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Regex Issue

Is anyone can help me that will be so appreciate:)

My question is: when i use 'If' my regex can grab data of city and postal code,,,,but if I use 'while' to loop those data, I can't grab any data of city and postal code, I don;t know why.......But I have to use 'while'  because in datatable have two different city and postal code,  so I need Loop,,,,please any one help me:)

this is my example code:
Pattern p9 = Pattern.compile('City\\s*(?:<[^>]+>){1,}\\s*:([^<]+)');
            Matcher m9 = p9.matcher(myHtmlText);
            string dt1;
            string City;
            string Pcode;
            string [] str;
            while(m9.find()) {
                dt1 ='(<[^>]*>|&nbsp;)','');
                str = dt1.split('\\,');
            city = str[0];
            //Postal Code
            Pcode = str[1];
Can you please provide an example of your myHtmlText so that I can run your code?  Also, are you trying to get multiple cities / postal codes out of the html?  Is that where the problem is?