# To extract specific information in the stack trace using regular expression [closed]

I encountered a problem at http://regexone.com/example/6? You can view the problem by clicking the link. There was required a regular expression to extract the method name, filename and the line number from a particular stack trace in an android development application.

I used the following regular expression to solve the problem :

at widget.List.([a-zA-Z]+).([A-Za-z]+\.java).(\d{3,4}).


The expression works for the problem but i don't think its the correct regular expression as there is no hat(^) and dollar ($) included in it. ## closed as unclear what you're asking by Jamal♦Aug 9 '15 at 20:27 Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question. • If you want to actually solve the problem rather than merely pass the test cases then you also need to take into account that packages can contain multiple components separated by a dot, that all names can begin with an underscore and can contain digits except at the first character, etc. – Peter Taylor Mar 5 '13 at 11:50 • You are falsely assuming a regex should contain ^ and $. – Eric Mar 5 '13 at 15:35

If you wish to include the hat ^ and dollar $ signs, then the regex can be rewritten as: ^.*\s+at widget\.List\.(\w+)$$(\w+\.java)\:(\d+)$$$

Ofcourse, you can still use \d{3,4} instead of \d+ but that'll result in you missing the errors in line numbers less than 100(like 1 to 99).
Similarly, you can use \w+ in place of [a-zA-Z]+ or simply, [A-z]+ will work too.