我有下面的代码:
class MainAdapter extends RecyclerView.Adapter<MainAdapter.ViewHolder> {
private ArrayList<Webtoon> mWebtoon;
private Context context;
RecyclerView mRecyclerView;
RecyclerView.Adapter mAdapter;
private ArrayList<Webtoon> mWebtoons;
String[] imageUrl = {"https://shared-comic.pstatic.net/thumb/webtoon/183559/thumbnail/title_thumbnail_20160516123017_t218x120.jpg",
"https://shared-comic.pstatic.net/thumb/webtoon/183559/thumbnail/title_thumbnail_20160516123017_t218x120.jpg",
"https://shared-comic.pstatic.net/thumb/webtoon/557672/thumbnail/title_thumbnail_20150323145400_t220x202.jpg"};
public MainAdapter(ArrayList<Webtoon> webtoons) {
mWebtoons = webtoons;
}
@Override
public MainAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.row, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(MainAdapter.ViewHolder holder, int position) {
String title1 =(mWebtoons.get(position).getmUrl().replaceAll(":: 네이버 만화", ""));
String title2 = title1.replaceAll(":: 네이버 웹툰", "");
holder.mTitleTextView.setText(title2);
for (int i = 0; i < imageUrl.length; i++) {
Picasso.get().load
(imageUrl[i]).resize(500,400)
.into(holder.webtoonCoverImage);
}
}
@Override
public int getItemCount() {
return mWebtoons.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
public TextView mTitleTextView;
public ImageView webtoonCoverImage;
public ViewHolder(View itemView) {
super(itemView);
mTitleTextView = (TextView) itemView.findViewById(R.id.title_text_view);
webtoonCoverImage = itemView.findViewById(R.id.webtoon_cover_image);
}
}
输出:r1:1 r2:0 r3:1 r4:1
我不明白为什么r2不匹配?
我的环境是:
使用以下命令配置--prefix = / Applications / Xcode.app / Contents / Developer / usr --with-gxx-include-dir = / usr / include / c ++ / 4.2.1 Apple LLVM版本10.0.0(clang-1000.11.45.5) 目标:x86_64-apple-darwin17.7.0 螺纹型号:posix InstalledDir:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin。
答案 0 :(得分:0)
c正则表达式风味为POSIX ERE acc。到clang-format regex syntax reference。在POSIX bracket expressions中,不支持常规的正则表达式转义序列,例如\s
,\d
,\w
甚至\]
。
[\s\S]
与[\\sS]
相同,并匹配反斜杠s
和S
字符。
但是,在POSIX正则表达式标准中,.
与任何个字符匹配,包括换行符,因此无需使用[\s\S]
解决方法。