我一直面临将正则表达式与 sed 一起使用的问题。我有一个像这样的字符串:
Call stack: [thread 0xac0aaa28]: | start | main main.m:37 | UIApplicationMain | GSEventRun | GSEventRunModal | CFRunLoopRunInMode | CFRunLoopRunSpecific | __CFRunLoopRun | __CFRunLoopDoSource1 | __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ | mshMIGPerform | _XCopyAttributeValue | _AXXMIGCopyAttributeValue | _copyAttributeValueCallback | -[NSObject(AXPrivCategory) accessibilityAttributeValue:] | -[UITableViewCellAccessibilityElement _accessibilityIsTableCell] | -[UITableViewCellAccessibilityElement tableViewCell] | -[UITableViewAccessibility(Accessibility) accessibilityCellForRowAtIndexPath:] | -[UITableView(UITableViewInternal) _createPreparedCellForRowAtIndexPath:] | -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] | -[MailViewController tableView:cellForRowAtIndexPath:] | +[NICellFactory tableViewModel:cellForTableView:atIndexPath:withObject:] NICellFactory.m:89 | +[NICellFactory cellWithClass:tableView:object:] NICellFactory.m:67 | -[SwipableTableViewCell shouldUpdateCellWithObject:] | -[SwipableTableViewCell updateCellWithObject:] | -[ThreadCellFrontView updateCellWithObject:] | -[ThreadSummaryView updateWithNugget:] | -[JavaUtilLinkedList init] LinkedList.m:49 | -[JavaUtilLinkedList initJavaUtilLinkedList] LinkedList.m:40 | +[NSObject alloc] | +[NSObject allocWithZone:] | _objc_rootAllocWithZone | class_createInstance | calloc | malloc_zone_calloc
其中有 main.m:37 |、LinkedList.m:95 |、NICellFactory.mm:89 | 等实例 等,即在文本伴侣中,我可以使用正则表达式匹配这些出现
[a-zA-z]+[.][m]+[:]+[0-9]+[ |]+
现在,当我尝试在 sed 中使用
sed 's/\[a-zA-z]+[.][m]+[:]+[0-9][ |]+/ /g'
Sed 似乎并没有取代这些实例。我也尝试过使用反冲,即
sed 's/\[a-zA-z\]+\[\.\]\[m\]+\[:\]+\[0-9\]+\[ |\]+/ /g'
仍然 sed 不能取代这种情况。
有人可以帮我理解我做错了什么吗?
谢谢