Thông tin được tìm nạp bằng yêu cầu JSONP, yêu cầu này chứa văn bản quảng cáo và liên kết đến hình ảnh quảng cáo. Tệp JSON và hình ảnh được tìm nạp từ buysellads. com hoặc buysellads. mạng lưới
Nếu bạn có bất kỳ câu hỏi hoặc thắc mắc nào, xin vui lòng gửi email
Đã cho chuỗi str, nhiệm vụ là kiểm tra xem chuỗi đã cho có phải là phần mở rộng tệp hình ảnh hợp lệ hay không bằng cách sử dụng Biểu thức chính quy.
Phần mở rộng tệp hình ảnh hợp lệ phải chỉ định các điều kiện sau.
- Nó phải bắt đầu bằng một chuỗi có ít nhất một ký tự
- Nó không nên có bất kỳ khoảng trắng nào
- Nó phải được theo sau bởi một dấu chấm [. ]
- Nó sẽ kết thúc với bất kỳ một trong các phần mở rộng sau. jpg, jpeg, png, gif, bmp
Ví dụ.
Đầu vào. str = “abc. png”
Đầu ra. đúng
Giải thích.
Chuỗi đã cho thỏa mãn tất cả các điều kiện nêu trên.
Đầu vào. str = “tôi. jpg”
Đầu ra. đúng
Giải thích.
Chuỗi đã cho thỏa mãn tất cả các điều kiện nêu trên.
Đầu vào. str = “. gif”
Đầu ra. sai
Giải thích.
Chuỗi đã cho không bắt đầu bằng tên tệp hình ảnh[yêu cầu ít nhất một ký tự]. Do đó, đây không phải là phần mở rộng tệp hình ảnh hợp lệ.
Khuyến khích. Vui lòng thử cách tiếp cận của bạn trên {IDE} trước, trước khi chuyển sang giải pháp
Cách tiếp cận. Vấn đề này có thể được giải quyết bằng cách sử dụng biểu thức chính quy.
- lấy chuỗi
- Tạo một biểu thức chính quy để kiểm tra phần mở rộng tệp hình ảnh hợp lệ như được đề cập bên dưới
regex = “[[^\\s]+[\\. [?i][jpe?g. png. gif. bmp]]$]”;
- Ở đâu.
- [ đại diện cho sự bắt đầu của nhóm 1
- [^\\s]+ đại diện cho chuỗi phải chứa ít nhất một ký tự
- [ đại diện cho sự bắt đầu của nhóm 2
- \\. Đại diện cho chuỗi nên theo sau bởi một dấu chấm [. ]
- [?i] đại diện cho chuỗi bỏ qua phân biệt chữ hoa chữ thường
- [ đại diện cho sự bắt đầu của nhóm3
- jpe?g. png. gif. bmp đại diện cho phần cuối chuỗi có đuôi jpg hoặc jpeg hoặc png hoặc gif hoặc bmp
- ] đại diện cho kết thúc của nhóm 3
- ] đại diện cho kết thúc của nhóm 2
- $ đại diện cho phần cuối của chuỗi
- ] đại diện cho kết thúc của nhóm 1
- Khớp chuỗi đã cho với biểu thức chính quy. Trong Java, điều này có thể được thực hiện bằng cách sử dụng Mẫu. đối sánh[]
- Trả về true nếu chuỗi đã cho khớp với biểu thức chính quy, ngược lại trả về false
Dưới đây là việc thực hiện các phương pháp trên
C++
// C++ program to validate the
// image file extension using Regular Expression
#include
#include
using
namespace
std;
// Function to validate the image file extension.
bool
// C++ program to validate the
0
// C++ program to validate the
1
// C++ program to validate the
2____03
// C++ program to validate the
2// C++ program to validate the
5 // C++ program to validate the
6// C++ program to validate the
7// C++ program to validate the
8
// C++ program to validate the
2// image file extension using Regular Expression
0
// C++ program to validate the
2// image file extension using Regular Expression
2
// C++ program to validate the
2// image file extension using Regular Expression
4 // image file extension using Regular Expression
5
// C++ program to validate the
2// C++ program to validate the
1
// image file extension using Regular Expression
8// image file extension using Regular Expression
9 #include
0#include
1
// C++ program to validate the
2#include
3
// C++ program to validate the
2#include
5
// C++ program to validate the
2#include
7
// C++ program to validate the
2____14#include
0
// C++ program to validate the
2// C++ program to validate the
1
#include
3// image file extension using Regular Expression
9 #include
5#include
1
// C++ program to validate the
2#include
3
// C++ program to validate the
2using
0
// C++ program to validate the
2// C++ program to validate the
1
#include
3// image file extension using Regular Expression
9 #include
0#include
1
// C++ program to validate the
2#include
3
#include
3
namespace
0
namespace
1 namespace
2
// C++ program to validate the
1
// C++ program to validate the
2
// C++ program to validate the
2namespace
6
// C++ program to validate the
2____58namespace
9#include
1
// C++ program to validate the
2____62
// C++ program to validate the
2____64
// C++ program to validate the
2______66____67#include
1
// C++ program to validate the
2// Function to validate the image file extension.
0
// C++ program to validate the
2// Function to validate the image file extension.
2
// C++ program to validate the
2// Function to validate the image file extension.
4// Function to validate the image file extension.
5#include
1
// C++ program to validate the
2// Function to validate the image file extension.
8
// C++ program to validate the
2bool
0
// C++ program to validate the
2______82____83#include
1
// C++ program to validate the
2____86
// C++ program to validate the
2____88
// C++ program to validate the
2______000______001#include
1
// C++ program to validate the
2// C++ program to validate the
04
// C++ program to validate the
2____19 // C++ program to validate the
07
#include
3
// C++ program to validate the
09
Java
// C++ program to validate the
10
// C++ program to validate the
11
// C++ program to validate the
12 // C++ program to validate the
13
// C++ program to validate the
14 // C++ program to validate the
15
#include
3____017
#include
3____019 // C++ program to validate the
20 // C++ program to validate the
21 // C++ program to validate the
22
#include
3// C++ program to validate the
1
// C++ program to validate the
25// C++ program to validate the
3
// C++ program to validate the
25// C++ program to validate the
28
// C++ program to validate the
29// C++ program to validate the
30______031#include
1
// C++ program to validate the
25// C++ program to validate the
34
// C++ program to validate the
25// C++ program to validate the
36
// C++ program to validate the
25// C++ program to validate the
38
// C++ program to validate the
25// C++ program to validate the
40
// C++ program to validate the
25// image file extension using Regular Expression
4 // C++ program to validate the
43// C++ program to validate the
44// C++ program to validate the
45
// C++ program to validate the
29// image file extension using Regular Expression
9 #include
0#include
1
// C++ program to validate the
25#include
3
// C++ program to validate the
25// C++ program to validate the
53
// C++ program to validate the
25// C++ program to validate the
55
// C++ program to validate the
25// C++ program to validate the
57
// C++ program to validate the
25// C++ program to validate the
59
// C++ program to validate the
25// C++ program to validate the
61
// C++ program to validate the
25#include
7
// C++ program to validate the
25// image file extension using Regular Expression
9 // C++ program to validate the
66
#include
3#include
3
_______33____070
#include
3// C++ program to validate the
19 // C++ program to validate the
20 // C++ program to validate the
74 // C++ program to validate the
75
#include
3// C++ program to validate the
1
// C++ program to validate the
25namespace
6
// C++ program to validate the
25// C++ program to validate the
81____59____21
// C++ program to validate the
25// C++ program to validate the
85
// C++ program to validate the
25std;
4
// C++ program to validate the
25// C++ program to validate the
89std;
7#include
1
// C++ program to validate the
25// C++ program to validate the
93
// C++ program to validate the
25// Function to validate the image file extension.
2
// C++ program to validate the
25// C++ program to validate the
97// Function to validate the image file extension.
5#include
1
// C++ program to validate the
25// image file extension using Regular Expression
01
// C++ program to validate the
25bool
0
// C++ program to validate the
25// image file extension using Regular Expression
05bool
3#include
1
// C++ program to validate the
25// image file extension using Regular Expression
09
// C++ program to validate the
25bool
8
// C++ program to validate the
25// image file extension using Regular Expression
13____001#include
1
// C++ program to validate the
25// image file extension using Regular Expression
17
#include
3#include
3
#include
3
Python3
// image file extension using Regular Expression
21
// image file extension using Regular Expression
22
// C++ program to validate the
12 // image file extension using Regular Expression
24
// image file extension using Regular Expression
25
// image file extension using Regular Expression
26
// image file extension using Regular Expression
27 // image file extension using Regular Expression
28// image file extension using Regular Expression
29____130
#include
3____132
#include
3____134____030 // C++ program to validate the
31
#include
3
#include
3____139
#include
3______141// C++ program to validate the
30 // image file extension using Regular Expression
43// image file extension using Regular Expression
44// image file extension using Regular Expression
45
#include
3____147
#include
3____149
#include
3// image file extension using Regular Expression
4 // image file extension using Regular Expression
52// image file extension using Regular Expression
29 // C++ program to validate the
30// C++ program to validate the
30 // image file extension using Regular Expression
56// image file extension using Regular Expression
30
// C++ program to validate the
25// image file extension using Regular Expression
9 // image file extension using Regular Expression
60
#include
3____162
#include
3____164
#include
3______14// image file extension using Regular Expression
67// image file extension using Regular Expression
29// image file extension using Regular Expression
69
// C++ program to validate the
25// image file extension using Regular Expression
9 // image file extension using Regular Expression
72
#include
3____40// image file extension using Regular Expression
75
// C++ program to validate the
25// image file extension using Regular Expression
9 // image file extension using Regular Expression
60
// image file extension using Regular Expression
79
// image file extension using Regular Expression
80
// image file extension using Regular Expression
81// C++ program to validate the
30 namespace
9
// image file extension using Regular Expression
84// image file extension using Regular Expression
85
// image file extension using Regular Expression
86
// image file extension using Regular Expression
87// C++ program to validate the
30 std;
7
// image file extension using Regular Expression
84// image file extension using Regular Expression
91
// image file extension using Regular Expression
92
// image file extension using Regular Expression
93____030 // Function to validate the image file extension.
5
// image file extension using Regular Expression
84// image file extension using Regular Expression
97
// image file extension using Regular Expression
98
// image file extension using Regular Expression
99// C++ program to validate the
30 bool
3
// image file extension using Regular Expression
84#include
03
#include
04
#include
05// C++ program to validate the
30 // C++ program to validate the
01
// image file extension using Regular Expression
84#include
09
#include
10
C#
#include
11
#include
12
#include
13
using
#include
15
using
#include
17
// C++ program to validate the
14 #include
19
// C++ program to validate the
1
// C++ program to validate the
2____222
// C++ program to validate the
2// C++ program to validate the
20 // C++ program to validate the
74 #include
26#include
27#include
28
// C++ program to validate the
2// C++ program to validate the
1
#include
3____232
#include
3____234
#include
3______227______237namespace
9#include
39std;
7#include
39// Function to validate the image file extension.
5#include
39bool
3#include
39// C++ program to validate the
01#include
47