1
我有一個字符串表達式是這樣的:如何在字符串表達式中查找字符串模式Java?
(code name credits) or ((code name credits) and (code name credits))
我要承認所有(代碼名稱學分)組合的字符串,並用值替換它們。
代碼是字母和數字的組合。
名稱是單詞的組合,由單個空格分隔,單詞可以包含字母和數字。
貸方是一個數字。
每個組件都由標籤分開。
(代碼名稱學分)組合的實際例子如下:
IABIG-02 Computer Graphics 5
這是不相關的問題,但是這是我想達到的目標:
輸入:
(IABIG-02 Computer Graphics 5) or ((AIBJH88 Computer Vision 5) and (AIKKH10 Computer Architecture 5))
輸出:
T or (F and T)
你試過了什麼代碼?發表它。 您只需將字符串拆分爲「或」和「和」,然後去掉額外的括號。其餘的部分將是你在找什麼。 – Blitzkr1eg
這與我剛剛回答的問題非常相似 - [http://stackoverflow.com/questions/36787560/how-to-evaluate-custom-parenthesis-expression-in-c](http://stackoverflow.com/問題/ 36787560 /如何做評估,定製括號表達式-C)。這是C#,但不應該很難適應您的需求。 – ClasG
感謝您的建議@ Blitzkr1eg,Nicolas Filotto給出的答案給出了我想要的全部內容。 – Martin