Skip to main content

Hi, I want to get the sub string 'fact.cm_comp_sales_adjustment_factor__c.living_area_default_index_score__c' in the string  '[subj.cm_parcel__c.sqft__c]+[comp.cm_sale__c.sqft__c])*[fact.cm_comp_sales_adjustment_factor__c.living_area_default_index_score__c]' . But it can't return the true value. Anyone can help? Here is my code :

 

Pattern MyPattern = Pattern.compile('(?<=[)fact.+?(?=])');

Matcher MyMatcher = MyPattern.matcher('[subj.cm_parcel__c.sqft__c]+[comp.cm_sale__c.sqft__c])*[fact.cm_comp_sales_adjustment_factor__c.living_area_default_index_score__c]');

System.Debug(MyMatcher);

System.Debug(MyMatcher.matches());

 

and the debug result:

 

Regular Expression Problem

1 respuesta
  1. 20 jul 2022, 4:47 a.m.

    When I try to check it with Regex Tool. It can return the correct result. I don't know what is the difference between Apex and another language

     

    When I try to check it with Regex Tool. It can return the correct result.