我想寫一個函數,如果在該字符串中找到某個模式,將會打印一部分字符串。提取被符號包圍的字符串的一部分
我有字符串數組,包含以下內容:
pages = ["|stackoverflow.com| The website serves as a platform for users to ask and answer questions." , "|reddit.com| A social news aggregation, web content rating, and discussion website"]
當用戶輸入urlReturn(pages,"platform")
,函數應該輸出stackoverflow.com
我都試過,但無濟於事,幫助將不勝感激!
爲什麼 「stackoverflow.com」,而不是 「reddit.com」? –
由於串「平臺」出現在「stackoverflow.com」舉行的字符串中,而不是「reddit.com」舉行的地方 – Johny