> Howerver, I still didn't understand your code, could you give me some more >explains? In addition, I write similar code according to your format, >it doesn't work, could you please help me to take a look at it? >
The reason it does not work as is in your second example, is because this is a typical sub-expression finding and replacement issues in all CAS systems.
The expression you want to replace is there, but it is now build into the over all more complex expression you have (not like the simpler example you had before, where the expression we wanted to replace was there as is)
Hence, one needs to do more work to extract these expressions out and replace them back with your L1 and L2 using pattern rules.
For example, looking at part of one of your expressions below