You need to sign in to do that
Don't have an account?
LALALA
I can't get value of m.group(), please help me!:)
this is my code:
String myPlainText= 'CompanyName: Heodo Order Number: 2000157 Date Ordered: Wednesday, May 21, 2014 City: Auckland, 2241 State/Province: North Island, New Zealand Phone: 021735562';
Pattern p=Pattern.compile('Order Number: ([\\d]{7})');
Matcher m = p.matcher(myPlainText);
if(m.matches())
{
system.debug(m.group(1));
}
Decimal Ordernum = Decimal.valueOf(m.group(1));
OrderRecord__c record = new OrderRecord__c(CustomerEmail__c = email.fromAddress, CustomerName__c='NINI',
OrderNumber__c =Ordernum);
insert record;
my qusetion is:
i wanna get a value which is 2000157 from m.group(1). but i can't.
i don't know where have problems in my code, could you tell me and give me a right answer?
i am so appriciate!!
String myPlainText= 'CompanyName: Heodo Order Number: 2000157 Date Ordered: Wednesday, May 21, 2014 City: Auckland, 2241 State/Province: North Island, New Zealand Phone: 021735562';
Pattern p=Pattern.compile('Order Number: ([\\d]{7})');
Matcher m = p.matcher(myPlainText);
if(m.matches())
{
system.debug(m.group(1));
}
Decimal Ordernum = Decimal.valueOf(m.group(1));
OrderRecord__c record = new OrderRecord__c(CustomerEmail__c = email.fromAddress, CustomerName__c='NINI',
OrderNumber__c =Ordernum);
insert record;
my qusetion is:
i wanna get a value which is 2000157 from m.group(1). but i can't.
i don't know where have problems in my code, could you tell me and give me a right answer?
i am so appriciate!!
Shingo is correct, find will serve you best. See the code below. I adjusted the regex also so that it matches any length number, just in case you receive a shorter or longer order number.
Good luck!
If this answer helps you on your way, don't forget to select it as the best answer!
All Answers
Sample:
Shingo is correct, find will serve you best. See the code below. I adjusted the regex also so that it matches any length number, just in case you receive a shorter or longer order number.
Good luck!
If this answer helps you on your way, don't forget to select it as the best answer!