你如何向Facebook好友的收件箱发送消息[重复](How do you to send a message to facebook friend's inbox [duplicate])
这个问题在这里已有答案:
- 发送私信给朋友 9个答案
如何将私人消息发送到朋友的收件箱,类似于Spotify如何将曲目发送到用户的朋友收件箱。 我做了一些研究,但我找不到任何API来实现这一点。
This question already has an answer here:
- Send private messages to friends 9 answers
How do you send private messages to a friend's inbox similar to how Spotify sends tracks to a user's friends inbox. I have done some research but I have not been able to find any API to implement this.
原文:https://stackoverflow.com/questions/17856367
最满意答案
你会想使用
m
选项,它允许点匹配新行:Donec sed odio dui. *Nullam id dolor id nibh ultricies vehicula ut*
正则表达式
str.match(/\*(.*)\*/m)[1]
现场示例: http :str.match(/\*(.*)\*/m)[1]
你的表情会捕捉到第一个和最后一个
*
符号之间的文本,但是如果你想捕捉每一组*
之间的所有文本,那么你会想让.*
少一些贪婪
str.match(/\*(.*?)\*/m)[1]
现场示例http://www.rubular.com/r/rBLOnwy3By或者你可以告诉它简单地匹配所有非
*
字符,注意不需要m
选项,因为一个新的行字符会被一个否定的[^*]
字符类匹配:
str.match(/\*([^*]*)\*/)[1]
现场示例http://www.rubular.com/r/dhQzZ58ZzMYou'll want to use the
m
option which allows the dot to match new lines:Donec sed odio dui. *Nullam id dolor id nibh ultricies vehicula ut*
regex
str.match(/\*(.*)\*/m)[1]
Live example: http://www.rubular.com/r/11u9TreEOLYour expression will capture the text between the first and last
*
symbol, but if you want to capture all text between each set of*
then you'd want to make the.*
less greedy like
str.match(/\*(.*?)\*/m)[1]
Live example http://www.rubular.com/r/rBLOnwy3ByOr you could tell it to simply match all non
*
characters like, note them
option is not needed as a new line character would be matched by a the negated[^*]
character class:
str.match(/\*([^*]*)\*/)[1]
Live example http://www.rubular.com/r/dhQzZ58ZzM
相关问答
更多-
将s修饰符添加到正则表达式中. 匹配换行: $string =~ /(START)(.+?)(END)/s; Add the s modifier to your regex to cause . to match newlines: $string =~ /(START)(.+?)(END)/s;
-
根据您的行结束样式,您可以使用[^\n]*来匹配换行以外的任何内容,或者使用[^\n\r]*来匹配除换行和回车之外的任何内容。 Depending on your line ending style, you could either use [^\n]* to match anything other than line feeds, or [^\n\r]* to match anything other than line feeds and carriage returns.
-
在我看来,你正在寻找类似以下的东西。 ^(?=.*\D{2,})[-.^\d]+$ 现场演示 It seems to me you are looking for something like the following. ^(?=.*\D{2,})[-.^\d]+$ Live Demo
-
包含新行的正则表达式匹配(Regex match including new line)[2022-12-08]
你会想使用m选项,它允许点匹配新行: Donec sed odio dui. *Nullam id dolor id nibh ultricies vehicula ut* 正则表达式 str.match(/\*(.*)\*/m)[1]现场示例: http : str.match(/\*(.*)\*/m)[1] 你的表情会捕捉到第一个和最后一个*符号之间的文本,但是如果你想捕捉每一组*之间的所有文本,那么你会想让.*少一些贪婪 str.match(/\*(.*?)\*/m)[1]现场示例http://w ... -
如果你正在研究一段较短的代码,那可能呢? 情况1: >>> import re >>> input_data = open('path/file').read() >>> result = re.search(r'.*(string match\s*.*)$', input_data, re.DOTALL) >>> print(result.group(1)) string match string log 5 string log 6 案例2: >>> import re >>> input_data ...
-
使用正则表达式匹配HTML(Using regex to match HTML)[2022-10-08]
以下代码应该工作: String str = "Johnny Smith: My favorite color abc: is pink
"; Pattern p = Pattern.compile("(?:>|^)([\\w\\s]+)(?=: ...
" + "Sarah: My favorite color is dark: blue
" + "Johnny: Let's swap: genders?
" + "Sarah: OK: sure!
" + " -
使用#C ,您可以使用RegexOptions.Singleline编译器标志。 使用单行模式,其中( . )匹配每个字符(而不是除\n之外的每个字符) 而不是RegexOptions.Singleline编译器标志,您可以通过在正则表达式的一开始放置一个内联修饰符来获得相同的效果。 Regex.Match(input, @"(?s)foo.*bar"); Using #C, you can use the RegexOptions.Singleline compiler flag. Use single ...
-
您可以在正则表达式中使用单行和多行标记,如下所示: ^$.* 工作演示 顺便说一句,如果你在行中有多个空格,那么你可以使用: ^\s*$(.*) 然后从捕获组中获取内容 You can use single line and multiline flag in a regex like this: ^$.* Working demo Btw, if you have multiple white spaces in the line, then you could use: ^\s*$(.*) An ...
-
如果要保留BOM,可以使用/^(?:\xEF\xBB\xBF)?/mg正则表达式在行的开头匹配。 You can use the /^(?:\xEF\xBB\xBF)?/mg regex to match at the beginning of the line anyway, if you want to preserve the BOM.
-
您可以使用此正则表达式使其工作: ~\b(?:https?://|www)[^"\\\s]+~ 当我们遇到任何空格(包括换行符)时,否定字符类中的\s将停止匹配。 RegEx演示 You can use this regex to make it work: ~\b(?:https?://|www)[^"\\\s]+~ \s inside negated character class will stop matching when we encounter any whitespace (includ ...